Narzędzia osobiste
Start Blog Buildout for Plone 3 with deliverance on WSGI

Przejdź na skróty do treści. | Przejdź do nawigacji

Buildout for Plone 3 with deliverance on WSGI

by Wojciech Lichota — last modified Jul 12, 2009 06:45 PM

In this article I want to show how to create development and production instances of Plone (3.3 rc4) with deliverance (0.3 - trunk version). All components lives in WSGI environment and cooperated with Apache HTTP server.

I made this article because most of tutorials available on web use some strange techniques, like hacks, rolling out or manual paths configuration. Not bed is official tutorial but there is to many manual steps (like running mkzope2instance) and it doesn't show how to use deliverance. My development buildout is quite similar to solution described in six feet up blog post.

My solution is designed to be as simple as possible:

  • only few commands
  • generates all necessary config files (for paster, apache, mod_wsgi)
  • easy for development
  • fast in production

Development instance

This instance will help during development of deliverance theme. Programmer or designer must edit ruleset - definition of transforms that deliverance should perform on theme and content taken form Plone.

Ingredients

Frontend HTTP server (Apache2 with mod_rewrite)
Listen on port 80, recognize virtual hosts and makes rewrites to Paster
Backend HTTP server (Paster)
Listen on non-privileged port (>1024), creates WSGI stack, serves static content (e.g. theme files)
Theme engine (Deliverance)
Change layout of website
Main application (repoze.zope2)
Allow Zope2 application exist in WSGI environment
Content Management System (Plone)
CMS based on Zope2, simplifies creating and managing of website content

Installation

Download and extract all files from plone_deliverance_wsgi.tar.gz archive:

cd /var/lib/zope
wget http://lichota.pl/blog/uploads/plone_deliverance_wsgi.tar.gz
tar -xvzf plone_deliverance_wsgi.tar.gz
cd plone_deliverance_wsgi

Edit settings.cfg and configure basic settings like: domain name (be default deliverance.example.com, port number (default 8080) or admin password (admin).

If chosen domain name is not configured in any DNS, you can add it to your /etc/hosts file, and point in to 127.0.0.1.

Run buildout:

python2.4 bootstrap.py
./bin/buildout -vc buildout-devel.cfg

Configure and restart apache:

sudo cp ./etc/deliverance.example.com.conf /etc/apache2/sites-enabled
sudo /etc/init.d/apache2 reload

Now you can start Paster:

./bin/ctl fg

ZMI will be available at address http://127.0.0.1:8080/manage.

Using

When everything is ready you can you three url's:

Using first address you can omit deliverance transforms, so you will see clean plone interface. With this address you can add, edit and manage content of website.

Next two addresses use deliverance engine. Theme and transform rules are located in ./src/theme directory. All files in this directory are served by egg:Paster#static middleware. So for example main theme file is available at address http://deliverance.example.com/theme/theme.html

In archive with buildouts I included skin (released on Creative Common license) with very simple ruleset. This ruleset (./src/theme/rules.xml) takes some part of pages generated by Plone and insert it in theme. More informations about writing such ruleset you can find at deliverance documentation.

In development instance theme and ruleset is parsed on every request, so it's slower but you do not need to restart paster after every change.

Development instance has some useful Plone products - Products.DocFinderTab, stxnext.pdb. It use also egg:Paste#evalerror middleware that allows interactive debugging.

Sample deliverance theme

Theme layout is based on colorus template created by Reality Software and released by Flash Gallery under the Creative Commons Attribution 3.0 license.

Ruleset defines very simple transformations - copy some tags from head, removes unnecessary divs (e.g: <div class="portletWrapper">...</div>), copy content (title, top menu, portlets, page content and footer).

Rules uses CSS selectors (only in v0.3) which are much more user friendly than XPath syntax.

Production instance

When website is ready we need move it to production server. It means that we need to create production instance. In this configuration Apache with mod_wsgi creates WSGI stack, so separated (backend) HTTP server is not needed.

Installation

Information how to install Apache2 with mod_wsgi you can find in mod_wsgi Wiki. Remember that mod_wsgi must use python 2.4.x. If default python interpreter at server is newer than 2.4 (2.5 or 2.6) you must compile mod_wsgi form source and set python version before executing make:

cd /tmp
wget http://modwsgi.googlecode.com/files/mod_wsgi-version.tar.gz
cd mod_wsgi-version
./configure --with-python=/usr/bin/python2.4
make
sudo make install

Now lets create instance. Download and extract all files from plone_deliverance_wsgi.tar.gz archive:

cd /var/lib/zope
wget http://lichota.pl/blog/uploads/plone_deliverance_wsgi.tar.gz
tar -xvzf plone_deliverance_wsgi.tar.gz
cd plone_deliverance_wsgi

Edit settings.cfg and change domain name, admin password and number of processes. In my opinion (based on some load tests) best performance of website is when number of processes is equal to number of CPU's (or CPU cores if such exists). Every process can also use few threads. Increasing threads number increase performance in small extent, so I suggest 2 threads.

Run buildout:

python2.4 bootstrap.py
./bin/buildout -vc buildout-production.cfg

You can also copy ZODB database file (./var/filestorage/Data.fs) from development instance to production server. Now you must copy created on development instance theme an place it in ./src/theme.

Because mod_wsgi will create few separated applications (in few processes and threads) database (ZODB) must be accessible simultaneously. ZEO server (build by buildout recipe) will take care of it. We just need to start it:

./bin/zeoserver start

Configure and restart apache:

sudo cp ./etc/deliverance.example.com.conf /etc/apache2/sites-enabled
sudo /etc/init.d/apache2 reload

Zope will be not running on separated port. So to access ZMI there must be special address - http://zmi.deliverance.example.com

In production configuration deliverance rulset and theme is parsed only once - at application start. So when you edit something in this files you must restart apache.


Download the buildout used in this article (52 KB)

Powered by DISQUS comment system