PythonProducts (1.0beta2)
- PythonProducts download link: http://plone.org/products/pythonproducts/releases
- Homepage of PythonProducts: http://plone.org/products/pythonproducts/
- PythonProducts repository: http://codespeak.net/svn/z3/pythonproducts/
- Description source: http://codespeak.net/svn/z3/pythonproducts/trunk/README.txt
- Description
- A mechanism to construct Zope 2 products as regular python packages. This enables a python package to be deployed as a Zope 2 product using a similar strategy as Zope 3.
- Source Control
- http://codespeak.net/svn/z3/pythonproducts/
- Requirements
-
- Python 2.3.5 or higher in 2.3.x series
- Zope 2.8 or 2.9
- Five 1.2 or higher
- Installing
-
Uses regular python distutils for installation. Simply run:
python ./setup.py install --home /some/path/to/zope_instance_home
- Usage
-
Once pythonproducts has been installed, the standard practise of installing a python package as a Zope 2 product is as follows:
- edit (or create it if it doesn't exist already) $YOUR_PKG_SOURCE/configure.zcml and add the line <five:registerPackage package="." initialize=".initialize" />
- copy your python package to $INSTANCE_HOME/lib/python
- create a ZCML "slug" by creating the file $INSTANCE_HOME/etc/package-includes/yourpackage-configure.zcml and populating it with <configure package="yourpackage" />
- Explanation of Usage
-
Step 1: Your python package needs to register itself as a Zope 2 product. This is accomplished by using the new registerPackage directive. This directive takes a (required) "package" attribute which declares any python package as a Zope 2 product (with "." meaning this package). Another (optional) attribute is the 'initialize' attribute. If this attribute is defined, a function with that name will be invoked in a traditional Zope 2 style with a ProductContext instance as the sole argument.
Step 2: Your python package needs to exist somewhere on PYTHONPATH. With Zope 2.8, $INSTANCE_HOME/lib/python is added to the PYTHONPATH so copying your python package there ensures its somewhere in PYTHONPATH. But really your python package could be copied to any directory that exists on PYTHONPATH (ie /usr/lib/python2.3/site-packages).
Step 3: The standard way of registering a package with Zope 3 is to create a ZCML "slug" in the $INSTANCE_HOME/etc/package-includes directory. This file can be called anything as long as it ends with "-configure.zcml".