Tutorial

How To Install and Use Zope 2 and PostgreSQL on Ubuntu 13.10

Published on March 25, 2014
Default avatar

By Andrew Ho

How To Install and Use Zope 2 and PostgreSQL on Ubuntu 13.10

Introduction

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.

Install PostgreSQL

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

Zope Installation

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

   source bin/activate

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:

   http://download.zope.org/Zope2/index/

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

   mkzopeinstance

Change into that zope instance directory

   cd /home/server/zope

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)

   vi etc/zope.conf

find the “effective-user” directive, uncomment, and type in “postgres”. The line should look like this when done

   effective-user postgres

Install Psycopg2 and ZPsycopgDA

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:

   wget http://initd.org/psycopg/tarballs/PSYCOPG-2-5/psycopg2-2.5.2.tar.gz

uncompress

   tar xvfz psycopg*gz

install psycopg2

   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: https://pypi.python.org/pypi/ZPsycopgDA/

   https://pypi.python.org/packages/source/Z/ZPsycopgDA/ZPsycopgDA-2.4.6.zip#md5=c76a0e1c8708154dcf07d1362ea8c432

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

   easy_install Products.ZSQLMethods

Start Zope

   /home/server/zope/bin/zopectl start

Create Database

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

All done!

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>

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about us


About the authors
Default avatar
Andrew Ho

author

Still looking for an answer?

Ask a questionSearch for more help

Was this helpful?
 
4 Comments


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Kamal Nasser
DigitalOcean Employee
DigitalOcean Employee badge
July 21, 2014

@sanyam.khurana01: See the paragraph under “Now, you can use a web-browser to connect to Zope and use your database as well.

Yes, I’ve already done that, but the problem isn’t solved till now.

What I’ve done now is, installed postgresql separately, plone separately, how to establish connection between those?

Andrew SB
DigitalOcean Employee
DigitalOcean Employee badge
June 24, 2014

@sanyam.khurana01: Make sure that command is all on one line. I make it more clear above.

Hi there!

I was installing postgreSQL and reached this command :

pip install --pre –index-url=http://download.zope.org/Zope2/index/2.13.21/ Zope2

I got an error saying no such option --pre

Please help me with this !

Thanks :)

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Join the Tech Talk
Success! Thank you! Please check your email for further details.

Please complete your information!

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel