Previous Chapter | Up | Next Section | Contents

External methods and Pluggable brains


External methods9 and pluggable brains10 require some special care when used with distributed Zope products. Normally, external methods and pluggable brains are defined in Python source files stored in the "Extensions" subdirectory of a Zope installation. Distributions, however, should be self contained. In addition, when two products want to use extension files with the same name, it is undesirable for a distribution to update files in a central location such as the "Extensions" directory.

To overcome this problem, a naming convention can be used to associate an extension source file with a particular product. If an extension file name contains a dot ('.'), then the part of the name proceeding the dot will be interpreted as a product name. When the file is loaded, an attempt will be made to load the file from a product-specific Extensions directory, lib/python/Products/product-name/Extensions/file.py, where product-name is the product name, and file is the part of the extension file name following the dot. For example, suppose an external method or brain is defined using the file name foobar.util, then Zope will attempt to load the method or class files from the following files, in this order:

  1. lib/python/Products/foobar/Extensions/util.py
  2. Extensions/foobar.util.py
  3. Extensions/util.py
Previous Chapter | Up | Next Section | Contents