Random ...
February 2018
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28      
Tags ...

python+zope++:: Deliverance: Deliver us!
Posted at 08.Feb,2009 21:08  Comments 0 / Trackbacks 0 / Like this post!
Technorati tag(s):

I managed to sell plone's features to act as a departmental intranet cum documentation pool at my workplace.

Getting the functionalities they require are easy enough. However, when users started asking for custom skin, hairs started to fall.

Skinning plone takes some learning. I tried, and failed to meet users expectations. This is not uncommon, methinks.

Here's where deliverance comes in. Deliverance help make sitetheme-ing (quoting Paul Everitt) easier. However, I think deliverance is really a stop gap measure. Plone theming/skinning should not involve another app, introducing another level of complexity and point of failure.

I think the plone devs are looking for this to happen in plone 4.

So, what is deliverance?

In simple term here's what deliverance do:

take chunks of information from plone and stuff it in our theme.

There are two deliverance versions; the newer one (pointed out in the deliverance quickstart) and the older one available in pypi.

With the snapshot version, we can choose between using css selectors or xpath to select/stuff the chunks.

The older version <=0.3 makes use of xpath only.

So, here's my experience setting up deliverance as a proxy between apache and plone.

Initially I tried the snapshot version, since that's what the quickstart points to.

The installation failed after downloading the snapshot tar ball because the install script was looking for the tar ball at the wrong place.

So I had to do it manually. Went to deliverance/src/deliverance, and did a python setup.py install.

Once installed, I had to customize deliverance.xml for:

  • ip:port to listen to
  • where to proxy to, and whether we require rewrite
  • where the theme is located
  • the rules that decide which chunks go where

Here's my deliverance.xml snippet:

 deliv]$ more etc/deliverance.xml 


  <proxy path="/_theme">
    <dest href="{here}/../theme" />

 <proxy path="/">                                                           
    <dest href="http://localhost:8080/Plone" />                              
    <response rewrite-links="1" />                                           
  <theme href="/_theme/theme.html" />                                        

    <replace content="children:#content" theme="children:#right" />
    <replace content="children:#portal-globalnav" theme="children:#nav" />
    <replace content="children:#portal-breadcrumbs" theme="div.#box1" />
 <replace theme="//ul[@id='portal-globalnav']"
           content="//div[@id='left']/ul/*" nocontent="ignore" />



It takes some time investigating which css selectors go where. Firebug add ons for firefox comes in handy in this situation.

Running the proxy, everything looks ok. However I had links with query strings and search results that went 404s.

Following a brief query at #zope, I decided to try out deliverance 0.21 and forgo the snapshot bundle.

Here's how I installed it:

 $easy_install Deliverance

This version also requires a rule file and a theme uri. We need to specify the addresses and ports to bind to and where to proxy to.

Running it:

 bin/deliverance-proxy -s ip.add:8000 -p http://localhost:8088  \      --theme=http://somedomain.com/theme/theme.html \
 --rule=file:////opt/Plone-3.1/Python-2.4/deliv0.21/minimal.xml --debug --rewrite --debug --request-log

We needed to put our theme files at an accessible web server.

There's a --new-layout=DEST_DIR option, but I can't find the binary to run it.

The rules "verb" are different compared to the snapshot version; and this version only understands xpath.

Here's an example rule file, minimal.xml:

  <rules xmlns="http://www.plone.org/deliverance">
 <append-or-replace theme="//head" content="//head/title" nocontent="ignore" />
 <prepend theme="//head" content="//head/link" nocontent="ignore" />
 <append theme="//head" content="//head/script" nocontent="ignore" />
 <prepend theme="//head" content="//head/style" nocontent="ignore" />
 <append theme="//head" content="//head/meta" nocontent="ignore" />
 <prepend theme="//head" content="//head/base" nocontent="ignore" />

 <copy content="//div[@id='content']" theme="//div[@id='contentright']" nocontent="ignore"  />
 <copy content="//div[@id='region-content']" theme="//div[@id='contentright']" />

One snag when working with the older version was finding the right documentation. So, here's where the older version documentation is at

The only thing left is putting in the rewriterule in httpd.conf:

 RewriteRule ^/(.*) http://ip.add:8000/VirtualHostBase/http/%{HTTP_HOST}:%{SERVER_PORT}/path/to/folder/VirtualHostRoot/$1 [L,P]

And, rejoice!

For the record, Deliver us (from evil) is a song by Warlord - way way way back when

Bookmark and Share

Is this entry helpful? Comments/Donate/Click some google ads.  
Trackback is http://myzope.kedai.com.my/blogs/kedai/228/tbping 

Post a comment