[Zope-CMF] Re: DeprecationWarnings for container events

Florent Guillaume fg at nuxeo.com
Wed Jan 18 10:33:17 EST 2006


Tres Seaver wrote:
> I'd like to get the CMF-trunk "clean" of Deprecation warnings, at least
> when running unit tests or starting up Zope, and those emitted by
> OFS.subscribers are the remaining ones I know about.
> 
> How do you mean for objects to handle the case where *they* need to
> respond to container events.  E.g., the CookieCrumbler needs to register
> / unregister itself as a traversal hook on its container;  there is no
> "external" subscriber which should be responsible for that (unlike, say,
> the catalog or the workflow tool).

Not if you think in term of placeful subscriber, but here the standard way 
is to have just a subscriber that is a function, and to do:

   <subscriber
       for=".interfaces.ICookieCrumbler
            zope.app.event.interfaces.IObjectEvent"
       handler=".CookieCrumbler.handleObjectEvent"
       />

from zope.app.container.interfaces import IObjectMovedEvent
from OFS.interfaces import IObjectWillBeMovedEvent

def handleObjectEvent(ob, event):
     """Notification from the event service.
     """
     if IObjectMovedEvent.providedBy(event):
         if event.newParent is not None:
             # here register hook
     elif IObjectWillBeMovedEvent.providedBy(event):
         if event.oldParent is not None:
             # here unregister hook

> WRT content, do you have code in hand which makes the catalog and
> workflow tools subscribers, so that we could rip out the
> 'manage_afterAdd' and 'manage_beforeDelete' from the content base class?

No I haven't done that yet even in CPS (for lack of time, not because of 
difficulty).

Florent

-- 
Florent Guillaume, Nuxeo (Paris, France)   CTO, Director of R&D
+33 1 40 33 71 59   http://nuxeo.com   fg at nuxeo.com


More information about the Zope-CMF mailing list