[Zope-dev] Subproducts in a Zope Python Product

Phillip J. Eby pje@telecommunity.com
Thu, 08 Feb 2001 14:08:51 -0500


At 07:32 PM 2/8/01 +0100, Johan Carlsson wrote:
>Hi,
>
>I want to create a sub modul in one of my Python Products,
>because it gets more manageble.
>Accualy I have a bunch of Plugins I which files I want to manage
>in sub directories of the original Python Product.
>
>e.g. ./Products/MyProduct/PluginKind1 etc...
>
>How do I setup the Zope registration procedure.
>I just had a look at ZPattern and the only thing 
>it seem I have to do is import the module form MyProducts __ini__.py
>
>Is this assuption correct?

Not quite.  Zope only calls the registration ("initialize()") function in
your main __init__.py module, so if you want sub-packages to have
registration occur, you must have the main registration function call the
registration functions from your sub-packages.  See ZPatterns' main
__init__.py for an example of this.  I personally dislike having a
monolithic initialize() function, so I always have the __init__.py
initialize() call an initialize function in the individual modules or
subpackages.


>Are there any reasons I shouldn't use necesting Plugins (Plugins that
>can have Plugins)?

No reason at all.  However, technically you'd be using PlugInContainers,
since only PlugInContainers can contain PlugIns.  ZPatterns does this all
the time - note that a Specialist is a PlugInContainer, which can contain
Racks as PlugIns.  Racks are also PlugInContainers, and support Data
PlugIns being plugged into them.  LoginManager does the same thing, with
data PlugIns inside of UserSources inside of LoginManagers.