An Outdated Developer's Guide to Learning Zope (v1.0.3)

Itamar Shtull-Trauring <zope@itamarst.org>


Important: This guide was written for Zope 2.2 and is extremely out of date

Contents

1 Introduction

Zope is a web application environment developed by Digital Creations - DC for short.

This document is not going to tell you why you should use Zope. Instead, it intends to point out resources that will allow you to learn how to use Zope. For an introduction on how Zope works, visit http://www.zope.org/WhatIsZope. In this document I describe the different levels of knowledge using terms I borrowed from Advogato http://www.advogato.org - Apprentice, Journeyer and Master. As you advance in your knowledge you will advance in your category, until at last you are a Master, and you to answer Newbies' questions.

1.1 Conventions

If I refer to a file, unless I state otherwise this refers to a subdirectory of $ZOPEHOME/lib/python/. For example, If Zope is installed in /home/zope, then the file OFS/Image.py can be found in /home/zope/lib/python/OFS/Image.py.

I assume Zope is installed on your local machine, so that Zope can be accessed at http://localhost:8080.

1.2 General suggestions

  1. The Source is your friend. The Zope source code has lots of embedded documentation and examples - use it.
  2. http://www.zope.org has hundreds of Howtos, tips, Products, documentation.
  3. You can find lots of info at the Zope Documentation Project: http://zdp.zope.org
  4. Both O'reilly and Wrox will soon be publishing books on Zope, and other publishing houses will be as well in the near future. Till they're available, you can read the text of the O'reilly book at http://www.zope.org/Members/michel/ZB/.

2 Preliminaries

Before you start using Zope, you're going to need to learn a few things which will help you understand how it works.

2.1 Python

Python is the programming language in which Zope was written. Knowledge of Python is a must if you intend to start developing serious Zope applications, and will also help in understanding DTML and other basic parts of Zope. Zope currently uses Python 1.5.2, but in the future will be upgraded to use Python 2.x.

The main resource for Python is http://www.python.org. The documentation section at http://www.python.org/doc/ has most or even all of the info you need to learn Python, starting with the Tutorial http://www.python.org/doc/current/tut/tut.htmland moving onwards from there.

There a number of books written about Python -- there's a complete list at http://www.python.org/psa/bookstore/. I especially liked Python Essential Reference (http://bn.bfast.com/booklink/click?sourceid=10922&ISBN=0735709017) which as the title says, is an essential Python reference.

There's an introductory talk on Python at http://shell.rmi.net/~lutz/talk.html.

The Python development team's homepage is http://www.pythonlabs.com, and the Python CVS, bug reporting system is at http://python.sourceforge.net.

2.2 HTTP, CGI, Cookies

A nice tutorial on how the web works can be found at http://www.stud.ifi.uio.no/~lmariusg/download/artikler/HTTP_tut.html.

The main way to communicate with Zope is via the HTTP protocol, and it gets its arguments via the CGI protocol. Some knowledge of both can be indispensable for debugging certain problems.

You can find the basic info for HTTP at the W3C http://www.w3c.org. See RFCs 2616, 2617 and 1867. You can find nice HTML versions of the RFCs at http://community.roxen.com/developers/idocs/, and the HTTP 1.1 RFC (2616) at http://www.w3.org/Protocols/rfc2616/rfc2616.html.

You can learn about cookies at http://home.netscape.com/newsref/std/cookie_spec.htmland RFCs 2109 and 2965.

The main reference for the way CGI works can be found at http://Web.Golux.Com/coar/cgi/.

3 Zope Newbie

OK, you've installed the latest version of Zope (http://www.zope.org/Products/Zope). Now what?

The single most complete resource for newbies is the upcoming O'Reilly book Zope: The Definitive Guide, by Amos Latteier and Michel Pelletier (the title is inaccurate - the book mainly covers the basics of using Zope). The book has not yet been published, but you can read the existing text at http://www.zope.org/Members/michel/ZB/. While not totally finished, the existing text contains major amounts of useful information, and it's getting better every day. All the resources I mention in the Newbie section probably have equivalent info in the book, so check there first.

Another great resource is Zope's online help - this can be accessed by clicking the Help button in any management screen, or at http://localhost:8080/HelpSys. It includes help for management screens, an API reference for DTML developers, and in newer versions of Zope (2.2.3 and later) a DTML reference as well.

Other useful resources for newbies:

A lot of Zope documentation can be found at http://www.zope.org/Documentation, including many useful Howtos and tips.

3.1 ZCatalog

The ZCatalog is Zope's built in indexing and searching engine, used to catalog Zope objects. You can learn about it at:

4 Zope Journeyer

Now that you've mastered Zope basics, its time to move on, and learn more about how Zope works internally.

4.1 Zope APIs

In order to work with Zope's internals, you need to know its APIs. In addition to the public ones documented in Zope's online help, you can find more info about Zope's internal APIs by:

4.2 Creating Zope Products

Extending Zope by adding Products is the standard way of creating advanced Zope applications. There are two main references for this:

4.3 ExtensionClass and Acquisition

ExtensionClass is a Python package that allows developers to create, in C, classes for Python that can be subclassed in Python. It's used for the Acquisition and Persistence support in Zope.

4.4 ZODB, Persistence and Transactions

ZODB is Zope's built-in object database. Objects that are stored in it must inherit from the Persistence class (an ExtensionClass). ZODB is a transactional database.

4.5 Creating custom DTML tags

DTML allows you to create your own custom tags. Check out the Mailhost product's <dtml-sendmail> tag in Products/MailHost/SendMailTag.py in your Zope install for an example, and also the MIMETools products (Products/MIMETools).

There's a Howto that explains how: http://www.zope.org/Members/z113/1.

4.6 Pluggable Brains

ZCatalog and ZSQL searches can use ZClasses or Python classes as pluggable brains, to give some ``intelligence'' to the returned records. You can learn about them at http://www.zope.org/Documentation/Guides/ZSQL-HTML/ZSQL.1.4.6.4.html.

4.7 Debugging

5 Zope Master

Having mastered the knowledge required of a Journeyer and Apprentice, you are now a Zope Master. That doesn't mean there's nothing left for you to learn - quite the opposite in fact. This is just an overview of the different topics you can look into in more depth.

5.1 Zope Core Development

Keeping up with the latest Zope developments is very important.

5.2 Custom ZODB Storages

The ZODB is usually stored in a FileStorage type storage, in a file called Data.fs. However, you can store it in other types of storage as well:

5.3 Zope Enterprise Objects

ZEO extends ZODB by turning it into a distributed object database. This lets you serve the same Zope database from different machines, test development code on the same database as your live site, and other uses. Find out more at http://www.zope.org/Products/ZEO.

5.4 Caching

There are two sorts of caching - internal Zope caching and HTTP caching. For info on HTTP caching, check out http://www.mnot.net/cache_docs/. You can see of an example of how Zope implements these headers in OFS/Image.py in the FILE class. Some information on using caching headers in Zope can be found at http://www.zope.org/Members/htrd/howto/caching?pp=1.

The next version of Zope (2.3) will contain a Caching Manager that will allow internal caching: http://dev.zope.org/Wikis/DevSite/Projects/CacheManager/.

5.5 Discussion Groups

There a number of different products implementing discussion abilities for Zope. The two main ones are Squishdot (http://www.squishdot.org) and ZUBB (http://www.zope.org/Members/BwanaZulia/ZUBB).

5.6 ZPatterns

ZPatterns is an advanced development framework for Zope, including an event model, generic data providers, and lots of really complex, cool stuff you'll really love once you figure out how to use them. Which can take a while. http://www.zope.org/Members/pje/ZPatternshas the product and some documentation.

5.7 Membership and User Sources

Zope by default only lets you store users in the ZODB and authenticate using Basic HTTP Authentication. If you want to store your users in a SQL database, get them off LDAP, or authenticate using cookies, you need an alternative to Zope's User Folder.

The most advanced alternative is LoginManager (http://www.zope.org/Members/tsarna/LoginManager), that lets you plug-in different authentication methods and user sources. Getting users off SQL/LDAP/Windows/passwd is very easy, you just need to write the correct methods: http://www.zope.org/Members/jok/SQL_based_LoginManager is an example of how to use SQL. You can find other, less general, methods of getting users at http://www.zope.org/Products/user_management.

The Membership Product (http://www.zope.org/Members/Bill/Products/Membership) gives you support for membership - allowing users to join, choose a password, set their preference, etc..

5.8 Portal Toolkit

PTK has everything you'd expect of a portal, and allows you to develop your own custom ones. The best example is of course http://www.zope.org, which is running an ancient version of the PTK. You can find out more at http://www.zope.org/Products/PTK.

5.9 Scheduling

Scheduling events in Zope can be done in two ways:

  1. Externally, for example using cron: http://www.zope.org/Members/lalo/cron, http://www.zope.org/Members/phd/cron-zope.
  2. Internally, using the Xron product: http://www.zope.org/Members/lstaffor/Xron.

5.10 XML

Zope has extensive XML support, including access to the ZODB using the DOM API. The next version of Zope will have support for XSLT and better XML and DOM support. You can find out more at the XML Wiki: http://www.zope.org/Wikis/zope-xml/FrontPage.

5.11 XML-RPC, SOAP and ZPublisher.Client

Zope can be accessed not only using HTTP, FTP and WebDAV, but also by RPC mechanisms such as XML-RPC.

5.12 Session Management

The next or maybe next-next version of Zope will contain built-in session management (http://dev.zope.org/Wikis/DevSite/Projects/CoreSessionTracking/). Until then, you can choose from a number of different session Products:

  1. SQL sessions: http://www.zope.org/Members/anthony/software/SQLSession
  2. Memory-based sessions: http://www.zope.org/Members/hungjunglu/Products/HappySession
  3. Filesystem sessions: http://www.zope.org/Members/gaaros/FSSession
  4. Cookieless sessions: http://www.zope.org/Members/czimmet/CookieLess

5.13 eCommerce

There are a number of ecommerce products for Zope.

There's a zope-commerce mailing-list - see A.2 for info on subscribing.

5.14 Perl Methods

Yes, you can use Perl from Zope! http://www.zope.org/Wikis/zope-perl/FrontPageis the place.

5.15 Virtual Hosting and other URL mangling

SiteRoot is a nifty product that allows you to mess around with the way Zope thinks about its base URL. It allows you to do virtual hosting from Zope, and some more dangerous and useful stuff: http://www.zope.org/Members/4am/SiteAccess2.

5.16 I18N and L10N

There a number of products for internationalization and localization. You can find them at http://www.zope.org/Products/internationalization. The next version of Zope will contain some support for skinnable management screens - see http://dev.zope.org/Wikis/DevSite/Projects/SkinnableAndLocalizableObjects/

5.17 Other Useful Tools

A. Getting Help

At some point, you're going to get stuck. That's when you need to ask someone for help. There's always someone nice on the mailing-lists or IRC who'll help you, so feel free to ask.

A.1 Commercial Support

You can get commercial support for Zope from a number of companies, including of course Digital Creations: http://www.zope.org/Resources/ZSP.


A.2 Mailing lists

Zope has a number of busy mailing-lists, on a number of topics including ecommerce, PTK and internationalization. For a full list of lists and instructions on subscribing visit http://www.zope.org/Resources/MailingLists. There are nice searchable archives of some of the lists at http://zope.nipltd.com/public/lists.html.

A.3 IRC

There's a busy #zope channel on irc.openprojects.net. Recent topics included bouncing sheep and LYX. Sometimes we even discuss Zope. Logs can be found at http://charizard.blazingfast.net/~irclord/zope-logs/.

A.4 Reporting bugs

Think you've found a bug in Zope? Submit it at http://classic.zope.org:8080/Collector.