[Zope] ZClass metatype question

Dieter Maurer dieter@handshake.de
Tue, 11 Dec 2001 22:02:37 +0100


Mag. Martin Sperl writes:
 > I am creating a Product with several ZClasses based on ZObjectManager.
 > Most of these are nested classes, so that class b is defined within
 > class a and thus class b is only available in an instance of class a for
 > addition.
 > 
 > So far so good, but my problem is that within an instance of class b
 > there should be other instances of class b and this only works if I
 > create class b in the Product folder. There are several such cases and
 > my selection of possible classes to add gets very large and is not
 > manageable...
You have several options:

  *  Use a single factory for a set of related ZClasses (each factory
     object gives you one entry in the add list; thus, reducing
     the number of factories gives you a smaller add list)

  *  Look at "PluginIndexes" (a product) and its associated
     use in "ZCatalog.manage_indexes" (or something along this line).

     It demonstrates the modern (Zope3) way to implement
     context specific add lists.

     "PluginIndexes" are not put into the global add list at
     all. Instead, the local add list for "manage_indexes" is
     build by looking for all Product Classes implementing
     a given interface.

     Probably, you will need to implement a special base class
     to make this feature available for your nested ZClasses.

  *  maybe, defining "all_meta_types" or "filtered_meta_types"
     for your nested ZClasses will make them available in itself
     (and other contexts).


Dieter