[Zope-CMF] quick question

Tres Seaver tseaver@palladion.com
Sun, 12 Aug 2001 20:05:55 -0400


Florent Guillaume wrote:

> CMFCore.PortalContent has this code:
> 
>     def manage_afterAdd(self, item, container):
>         """
>             Add self to the workflow and catalog.
>         """
>         #
>         #   Are we being added (or moved)?
>         #
>         if aq_base(container) is not aq_base(self):
>             wf = getToolByName(self, 'portal_workflow', None)
>             if wf is not None:
>                 wf.notifyCreated(self)
>             self.indexObject()
> 
> I don't understand the rationale behind the comparison of container and
> self. In what circumstances could we have the equality:
> 	aq_base(container) is aq_base(self) ?

> From my reading of ObjectManager, manage_afterAdd is called on
> the subchildren of item, so container is never self. And in any case,
> if manage_afterAdd has been called, there was a reason, so we should
> do our reindexing unconditionnaly. Isn't it ?
> 
> (Same thing in beforeDelete.)


The actual implementation of the ObjectManager protocol is as you
describe:  'manage_afterAdd' is called only on the added item.
There was some discussion of extending the protocol to the
container, for instance to permit the container to veto the
addition (or deletion) without needing to reimplement
'_setObject'/'_delObj'.


The code in PortalContent is trying to do the Right Thing in the

case where 'self' is really a container, and where the proposed
extension is in play.


Tres.
-- 
===============================================================
Tres Seaver                                tseaver@zope.com
Zope Corporation      "Zope Dealers"       http://www.zope.com