[Zope-dev] CatalogAware must come before ObjectManager

Michel Pelletier michel@digicool.com
Thu, 5 Aug 1999 12:18:09 -0400


> -----Original Message-----
> From: Kevin Dangoor [mailto:kid@kendermedia.com]
> Sent: Wednesday, August 04, 1999 10:27 PM
> To: zope-dev@zope.org
> Subject: [Zope-dev] CatalogAware must come before ObjectManager
> 
> 
> I don't know if this is a bug, or simply a function of how 
> things work...
> but it appears that a ZClass must list CatalogAware as a base 
> class before
> ObjectManager if you wish the CatalogAware functionality to 
> be there. If
> this is expected behavior, then this should probably be documented...

This is the intended behavior.  Both ObjectManager and CatalogAware
define a manage_afterAdd method.  The CatalogAware class must be
subclassed first in order for it's afterAdd to be called instead of
ObjectManagers.  This is identical behavior to python.  You're right, it
should be documented.

> 
> BTW, will it ever be possible to change the Base classes of a ZClass?
> 
It is possible, but only from python, and it is a *real* hack.  Doing
this is completely unsupported.  I might get shot for revealing the
technique.

Given a Product called 'YourProduct' that contains a Zclass called
'YourZClass' that you want to 'rebase', first, create a temporary ZClass
called 'TempZClass' in the same product.  'TempZClass' should be built
with the new order or types of subclasses that you want 'YourZClass' to
have.  Note that 'TempZClass' need not have anything in it, it just
needs to subclass the right classes.

Shut down Zope, run python1.5.2 in your lib/python directory, and
execute the following code:

>>> import Zope
>>> p = Zope.app().Control_Panel.Products.YourProduct 
>>> p
<Product instance at 849de28>
>>> p.YourZClass._setBasesHoldOnToYourButts(p.TempZClass._zbases[1:])
>>> get_transaction().commit()


-Michel

> Kevin
> 
> 
> _______________________________________________
> Zope-Dev maillist  -  Zope-Dev@zope.org
> http://www.zope.org/mailman/listinfo/zope-dev
> 
> (To receive general Zope announcements, see:
> http://www.zope.org/mailman/listinfo/zope-announce
> 
> For non-developer, user-level issues, 
> zope@zope.org, http://www.zope.org/mailman/listinfo/zope )
>