[Zope] setting up a ZClass - base class of PropertyManager? plus weird gradual broken product messages

Dieter Maurer dieter@handshake.de
Sun, 21 Apr 2002 21:36:33 +0200


A M Thomas writes:
 > ... "PropertyManager" not registered as ZClass base ...
 > Must I create my product in Python only to get PropertyManager cleanly?
No.

I see (at least) 3 options:

  1. you may consider "OFS: Folder" as base class.

     It is an Object Manager and a Property Manager (and several
     other types of managers).

     Apparently, it lacks the customizable "add list".
     But some people seem to have been able to
     get it by inheriting from both "OFS: Folder"
     and "ZClasses: Object Manager". But, that's not clean.

  2. You define a Python base class precisely for your ZClass.

     That's not a bad idea as it may allow you to later
     "rebase" your ZClass (i.e. add further base classes
     at a later time). This is not easy without such a
     base class.

     Initially, your class would just inherit from
     "OFS.PropertyManager.PropertyManager".

  3. You provide the missing registration as ZClass base
     for "PropertyManager". It can look like this:

	 from ZClasses import createZClassForBase
	 from OFS.PropertyManager import PropertyManager

	 createZClassForBase(PropertyManager,globals(),
			     'PMBase', 'Property Manager')

 > Also, I noticed a curious effect: I re-created my ZClass by ...
 > saving out the Class ID, then deleting the ZClass ...
 > Then I created a new
 > ZClass with the same name as the old one, and put in the saved ClassID,
 > ....
 > However, old instances of this ZClass _gradually_ started showing
 > "broken product" messages.  First one, then overnight, two more...
It might be necessary to restart your Zope.

   Breaking the connection between ZInstances and the origin ZClass
   and reconnecting as you did, is not an officially supported
   operation (as you surely know).
   This means, there are side effects, which an official support
   need to take into account:

     The class id is used as a module name in "sys.modules".

     When you change the class id of a ZClass, then probably neither
     is a new module (with the new name) created nor is the
     old module replaced in "sys.modules".

   Try to restart and see whether the effect disappears.


Dieter