mxm Proxy Tool
Simple Usage
You install the tool in the root of your site. Then you make a zpt page that can render the content.
This is the most simple example (simple_proxy.pt):
<html>
<body>
<div tal:content="structure here/mxm_proxytool/browse">
Proxy content
</div>
</body>
</html>
If you try and render that page in Zope by going to:
http://www.example.com/simple_proxy
it will show an empty page, as it has no proxy_url.
We can send it a proxy url via the query string:
http://www.example.com/simple_proxy?mxm_proxy_url=http://slashdot.org
The content of slashdot org will then be rendered in your site. If you click on any of the links on that page, you will continue to browse the site through your page.
WARNING: You must be carefull!
If you use this tool incorrectly, other people can make their own content look like yours. Eg. they can put a credit card payment form into your layout. With an url that comes from you.
So you really must use the allowed_urls flter to make a filter of legal urls that the proxy should show content from.
allowed_urls is a regex for allowed proxy_urls. A regex for allwing all content from slashdot.org could look like this:
http://slashdot.org(.*?)
So a safer example would look like this:
<div tal:define="proxy here/mxm_proxytool;"
tal:content="structure python:proxy.browse(allowed_urls='http://slashdot.org(.*?)')">
</div>
Tips! If you want to render content inside Plone, you need to convert it to Unicode, so that Plone can encode it as utf-8. So assuming that the site you are proxying is using latin-1 encoding, you can do it like this:
tal:content="structure python:unicode(proxy.browse(url, allowed_urls='http://slashdot.org(.*?)'), 'latin-1')">
Complete example of browsing slashdot.org. Using slashdot.org as a default url. Meaning that you don't have to pass the initial proxy_url in the query string. You can just enter:
http://www.example.com/slashdot_proxy
slashdot_proxy.pt:
<html>
<head>
<title>Slashdot</title>
</head>
<body>
<div tal:define="proxy here/mxm_proxytool;
url python:request.get(proxy.MXM_PROXY_URL_NAME, 'http://slashdot.org/')"
tal:content="structure python:unicode(proxy.browse(url, allowed_urls='http://slashdot.org(.*?)'), 'latin-1')">
</div>