Zope3 in Zope2

1 Introduction

Zope is an open source, flexible, platform independent web application server framework especially useful to build dynamic websites. You find more information about Zope via Zope's home page.

The current generation of Zope is Zope2. But the next generation, Zope3, is actively developped and brings lots of enhancements for application development. Zope2 applications will still live a long time and it is wishful to be able to use some of the advanced Zope3 concepts in Zope2 applications.

Five is one major project aiming to make Zope3 components available for Zope2 applications. It makes available Zope3 interfaces, ZCML, adapters and more.

On this page, you find my contributions to Zope3 in Zope2 use.

Currently, my contributions are either completely free, or covered by an open source or open content license. Note however, that I consider whether I will expressly forbid the use of my software by institutions of the European Union (Councel of Ministers, Commission, Parliament, ...). This is in protest against a recent decision of the Councel to make software patentable. This decision ignores a Parliament vote that pleaded to keep logic (algorithms, business rules) un-patentable. Of course, only new versions will be affected by such a change -- should it come.

The contributions consist of the package dm and several products building on top of dm. Usually, a product requires a minimal version of dm.

2 The dm package

This package contains elementary infrastructure for the Zope2 and Zope 3 integration.

Download version 0.1

3 Products

3.1 localevent

Events (and event subscriptions) are a major concept for loose integration of independent components.

Zope3 supports events and event subscriptions. However, its subscriptions are global. Many (local) services are interested in events generated in a specific subsite. A prominent example are catalogs that catalog objects in a subsite.

localevent is a Zope2 product. It provides a (persistent and local) local_event_subscription tool (in the sense of CMF tools). Other tools can use it to subscribe for (Zope3) events originating in the subsite rooted in the parent of the local_event_subscription instance.

As usual for Zope3 subscriptions, a subscription registers a factory, called a notifier. The notifier is called when an interesting event occurs. Notifiers registered with local_event_subscription must be picklable (unlike notifiers for global events). The interface IPicklableMethods of dm.z23.interfaces can be used to construct picklable notifiers from methods.

Often, the notifier needs to reference a persistent object located in the Zope site. In Zope3, each located object maintains its parent in an attribute. However, in Zope2, objects do not know anything about their ancestors. Instead, the hiearchy is dynamically determined through access paths and recorded in acquisition wrappers. These wrappers are not picklable. The IAqLessWrapper interface of dm.z23.interfaces helps to construct notifiers from methods of such objects. It replaces the object with a picklable proxy that stores its path and can resolve methods with a located object as first argument. When such a method is called, the original object is recreated and its corresponding method called.

See tests/testLocalEvent.py for an example, how IPicklableMethods and IAqWrapperLess can be used to obtain picklable notifiers.

Version 0.1 required version 0.1 (or later) of the dm package.

Download version 0.1

4 Installation

As this software integrates Zope2 and Zope3, you must have both versions installed. You must have generated the Zope3 extensions (e.g. by installing the Zope3 binary distribution for Windows or by calling make under Unix). The directory zope of Zope3 must be in the PYTHONPATH of your Zope2.

You must put the dm package somewhere on your PYTHONPATH. $INSTANCE_HOME/lib/python is a good place.

Products can be installed as usual for Zope2 products, e.g. in $INSTANCE_HOME/Products.

After these preparation, you can start your Zope2.

Dieter Maurer
Last modified: Mon Mar 7 21:51:06 CET 2005