calling python from zope

Duncan Booth duncan at rcp.co.uk
Mon Sep 4 05:01:33 EDT 2000


poparosa at aol.com (Poparosa) wrote in <20000902225426.22316.00002563 at ng-
md1.aol.com>:
>  How does one call python from zope?  As the zope tarball
>includs python, it stands to reason that it should be able to
>call it without much reconfiguration - right? 
>

There are at least three ways to call Python from Zope. These are (in order 
of increasing power and increasing complexity):

PythonMethods
External Methods
Python Products

PythonMethods have (almost) all the restrictions of DTML methods, but let 
you use normal Python syntax instead of baroque DTML syntax. My preferred 
way of using these is to use a DMTL method to format the HTML page to be 
returned, but which calls a PythonMethod to do any real processing.
To use PythonMethods you have to install the PythonMethod product, see 
http://www.zope.org/Members/4am/PythonMethod. Ordinary users on a Zope 
system can use PythonMethods if they are installed and permissioned.

External methods are simply functions that exist in a file in the 
Extensions directory. They may do anything that Python can do, but you 
cannot easily maintain state between calls to the Zope server. Related to 
external methods are 'pluggable-brains' which are simply classes defined in 
the Extensions directory and which may be wrapped around the result of 
database queries. You need direct access to the file system to write 
external methods.

Products are at the core of Zope, and let you define new objects with 
persistent state. Rather more complex, but once you get on top of these 
there are no limits to what you can do. Find the 'boring' product on the 
Zope site for a HowTo on writing Python Products and a framework you can 
use to base your own products on. http://www.zope.org/Members/gtk/Boring



More information about the Python-list mailing list