Category Archives: Zope/Plone

Zope and Apache HTTP Server working as reverse proxy

I folks,

If you want to create an scenario with a Zope working as production web site and other/s Zope working as application server, probably you are looking for the way to configure Apache as reverse proxy between the front row (web site and content) and the rear row (web applications). In this case, working with Zope makes the configuration be easier because it has a product (VirtualHostMonster) that does part of the work; “A Virtual Host Monster’s only job is to change the URLs which your Zope objects generate. This allows you to customize the URLs that are displayed within your Zope application, allowing an object to have a different URL when accessed in a different way“. This is very useful because in other way we should use a third-party module called ProxyHtml. mod_proxy_html is used to rewrite HTML code, specially links. But in our case, we only need to use the rewrite module (mod_rewrite) and the proxy module (mod_proxy).

Let’e get to work:

To redirect an application from a public server to a private server (private server does not need to has an Apache running) we should add the following code in the virtual host configuration file (/etc/apache2/vhosts.d/myhost.conf).

RewriteRule ^/Intranet/Apps/app1(.*) http://private.com:8080/VirtualHostBase/http/<strong>%{HTTP_HOST}</strong>:80/DOM/VirtualHostRoot/Intranet/Apps/app1/$1 [L,P]
ProxyPassReverse / http://private.com:8080/VirtualHostBase/http/<strong>%{HTTP_HOST}</strong>:80/DOM/VirtualHostRoot/

Note than in the second part of both rules the URL is compliant with the VHM requirements. First we found the rewrite and redirection to the private server (http://private.com:8080/VirtualHostBase/) and after the /http/ we find the host (here I use the Apache’s variale HTTP_HOST) where the VirtualHostMonster will do the reverse proxy. %{HTTP_HOST} is an Apache’s variable, and we can use it here or directly the name of the public server.

And this is all 馃檪 If you have any other experience or comment please don’t hesitate to comment here!

Publishing objects from Zope's products

Creating Zope homemade products is the best way to developing Python web applications without depending (if you don’t want) from Plone. Until last wednesday, I had tried some methods to manage Python’s objects directly from ZPT pages but didn’t work. Other problem with Zope is the documentation and the community, there are too few documentation, and the community of users/developers is too small (for Plone is bigger). Past wednesday my colleague Xavier finds a way to publishing Python’s object directly in a ZPT, when he was following an error log to solve an occurred error. The way is a KISS (Keep It Simple and Stupid) way. Every object in the application that you wants to publish, is mandatory that the object inherits from OFS.SimpleItem, and the object can be used from a ZPT, calling its methods and properties. This is very important for us because we are developing some Zope web applications, and we need a way to design, develops and testing the applications. Now with this discovering we can organize an application like an Object Oriented application without any method/module to pass data through the main core and the ZPT. And this can help us to use PyUnit or homemade scripts to testing the application and do it independent to the presentation layer.

e.g.: Python Class inherited from OSF.SimpleItem

1
2
3
4
5
6
7
8
##OurObject.py
# -*- coding: latin-1 -*-
import OFS.SimpleItem
 
class OurObject(OFS.SimpleItem.SimpleItem):
    def __init__(self, id = '', description = ''):
        self.id = id
        self.description = description

e.g.: Calling object inside a ZPT

29
30
<h1 tal:content="myInstance/id"></h1>
<input type="text" tal:attributes="value myInstance/description" />