[Zope-dev] Re: SVN: Zope/branches/2.10/ Collector #2307: ObjectCopiedEvent not dispatched to sublocations.

Philipp von Weitershausen philipp at weitershausen.de
Wed Jun 20 06:25:51 EDT 2007


Stefan H. Holek wrote:
> Log message for revision 76597:
>   Collector #2307: ObjectCopiedEvent not dispatched to sublocations.
>   
> 
...

> @@ -130,7 +131,15 @@
>      if OFS.interfaces.IObjectManager.providedBy(ob):
>          dispatchToSublocations(ob, event)
>  
> + at zope.component.adapter(OFS.interfaces.IItem, IObjectCopiedEvent)
> +def dispatchObjectCopiedEvent(ob, event):
> +    """Multi-subscriber for IItem + IObjectCopiedEvent.
> +    """
> +    # Dispatch to sublocations
> +    if OFS.interfaces.IObjectManager.providedBy(ob):
> +        dispatchToSublocations(ob, event)

Why are you subscribing to IItem if you really want to work only with 
IObjectManagers? The above code could simply read (quoting to avoid 
wrapping):

> @zope.component.adapter(OFS.interfaces.IObjectManager, IObjectCopiedEvent)
> def dispatchObjectCopiedEvent(obj, event):
>     dispatchToSublocations(obj, event)

That's not only more elegant, I reckon it's also a tad faster. To avoid 
even more typing, you could get rid of all of that code and simply 
register that "dispatchToSublocations" function directly for those two 
objects:

   <subscriber
       for="OFS.interfaces.IObjectManager
            zope.lifecycleevent.interfaces.IObjectCopiedEvent"
       handler="zope.app.container.contained.dispatchToSublocations"
       />

Sorry for commenting so late now that you've done all the merging, but I 
only noticed this today... :/


-- 
http://worldcookery.com -- Professional Zope documentation and training


More information about the Zope-Dev mailing list