Writing Zope Products

What's Missing Now?

If we were to release our simplehello project as it currently stands, no one would really want to use it. In addition to the problems mentioned above (e.g., the lack of unique ids for individual instances), our product lacks the management tabs that make Zope so user-friendly for administrators. It also fails to handle security permissions in a standard or easy way.

It is almost as easy to install these features as the others we have seen so far. For example, each tab is represented by a dictionary containing two name-value pairs, label and action. The value associated with label is what the user sees on the screen, while the value associated with action tells Zope which method should be invoked when someone clicks on the appropriate tab. To install your tabs in Zope, define a manage_options tuple in your object, the members of which are the dictionaries describing the tabs.

One of the most important items that we haven't addressed so far is user input. This is actually a pretty easy issue to address because Zope treats HTML form inputs as if they were standard parameters to a method. For example, consider the following HTML form:

<form action="manage_edit" method="POST">
    <p>id: <input type="text"
    <p>Title: <input type="text"
    <p><input type="submit"></p>

Clicking on the “submit” button will submit the name-value pairs for id and title to our product's manage_edit method. We can define that method with a signature like the following:

def manage_edit(self, id, title):
Within this method, we can retrieve the values of the id and title HTML form elements using the variables of the same names.


Zope products are a more advanced and sophisticated way to build Zope applications than DTML files, giving greater flexibility but also requiring greater discipline and understanding of the underlying mechanisms. Knowing how to write Zope products is something like knowing how to write mod_perl modules for Apache; it means that the underlying system is completely at your disposal.

Unfortunately, while programmers can take advantage of a rich API for creating their own Zope products, the lack of good introductory documentation has scared many people from trying. Our simplehello product demonstrates that with just a little code, you can get impressive and useful applications working in a short period of time.


email: reuven@lerner.co.il

Reuven M. Lerner is a consultant specializing in web/database applications and open-source software. His book, Core Perl, was published in January 2002 by Prentice-Hall. Reuven lives in Modi'in, Israel, with his wife and daughter.



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Re: At the Forge: Writing Zope Products

Anonymous's picture

Very nice article!
Greate list of the ready for use Zope products can be found on content management software info