Zope 2 is a powerful and easy-to-use web-based development framework. This is especially the case when used as a front-end for PostgreSQL.
When used together, high quality database applications with HTML / XML interface can be constructed quickly in a highly scalable, secure, and maintainable fashion.
Compared to the ease-of-use of the resulting system, the installation process is often non-trivial, as there is no single Debian/Ubuntu package that contains and installs all the necessary components. That is the gap that this tutorial aims to fill.
A major challenge to installing Zope + PostgreSQL has been the need to use an adapter that connects between these two. Psycopg2 has been a fast and reliable database adapter but can take a bit of custom trouble-shooting during the installation process from time to time.
The installation procedure documented below is confirmed to work for the versions of Zope, PostgreSQL, PsycopgDA, ZPsycopgDA listed below as examples. If you encounter any difficulties after following these steps, please post a comment and we will all work together to keep the tutorial fresh and relevant.
Before installing Debian or Ubuntu packages, it is best to change to superuser and perform an update of the package repository:
sudo su apt-get update
in case you want to unzip some of the zope related packages apt-get install zip
After that, simply install PostgreSQL (9.1.12 is the version in this example):
apt-get install postgresql
Install virtualenv, which is helpful to isolate the zope installation from rest of the Python environment on the VPS.
apt-get install python-virtualenv
make a directory in /home
mkdir /home/server cd /home/server
create a virtual python environment for zope installation
virtualenv --no-site-packages my_zope cd my_zope
activate the virtual environment
Install python-dev, which are needed to build Zope from source
apt-get install python-dev
Find out the newest Zope version number by using a web browser. You don’t have to download it, just note the version number for the next step:
Then install Zope (change 2.13.21 to a different version number as appropriate):
pip install --pre --index-url=http://download.zope.org/Zope2/index/2.13.21/ Zope2
We are ready to make a zope instance. For this example, we will assume that the zope instance directory will be /home/server/zope
Change into that zope instance directory
change ownership to the postgres user; this makes it easier for Zope to access PostgreSQL.
chown -R postgres:postgres *
change the zope configuration file to run Zope as postgres user (use any editor you like, I am just using vi as example)
find the “effective-user” directive, uncomment, and type in “postgres”. The line should look like this when done
Install the pre-requisite packages
apt-get install libpq-dev
Download the Psycopg package and find the most recent version by going to
http://www.init.d.org. Change the version number as appropriate:
tar xvfz psycopg*gz
cd psycopg2* python setup.py build python setup.py install
Next step is to add ZPsycopgDA to the Zope Products directory. This will link Zope to the Psycopg2 library.
Download the latest ZPsycopgDA (please change the file name asappropriate) from this site:
Install by unzipping and then moving the ZPsycopgDA directory into the Zope instance directory (e.g. /home/server/zope/Products)
unzip ZPsycopgDA*zip cd ZPsycopgDA* mv ZPsycopgDA /home/server/zope/Products
install the Zope ZSQLMethods product
Of course, to use the database, it must be created first. To do that, change into the postgres user.
su postgres createdb my_first_database
Now, you can use a web-browser to connect to Zope and use your database as well.
point your web browser to ip.address.of.server:8080, the Zope management interface will be displayed Log-in using the credentials your provided during mkzopeinstance select Z Psycopg 2 Database Connection from the drop-down menu for connection string, use the following: dbname=my_first_database user=postgres
If you are new to Zope and PostgreSQL, the next thing to do is create SQL methods to create tables, run queries, etc.
Write SQL by adding Z SQL Method objects (from drop down menu) in the Zope management interface.
<div class=“author”>Submitted by: <a href=“http://www.ExoMachina.com”>Andrew Ho</a></div>
Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in our Questions & Answers section, find tutorials and tools that will help you grow as a developer and scale your project or business, and subscribe to topics of interest.Sign up