[Zope-dev] Re: SVN: Zope/branches/2.10/ Collector #2307: ObjectCopiedEvent not dispatched to sublocations.
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) [EMAIL PROTECTED](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 ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
[Zope-dev] Re: SVN: Zope/branches/2.10/ Collector #2307: ObjectCopiedEvent not dispatched to sublocations.
I took my cues from how ObjectModifiedEvent is handled. I figured copied and moved should be treated the same. Also, there is this comment in OFS/subscribers.py: # The following subscribers should really be defined in ZCML # but we don't have enough control over subscriber ordering for # that to work exactly right. # (Sometimes IItem comes before IObjectManager, sometimes after, # depending on some of Zope's classes.) # This code can be simplified when Zope is completely rid of # manage_afterAdd co, then IItem wouldn't be relevant anymore and we # could have a simple subscriber for IObjectManager that directly calls # dispatchToSublocations. Cheers, Stefan On 20. Jun 2007, at 12:25, Philipp von Weitershausen wrote: 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) [EMAIL PROTECTED](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? -- Anything that, in happening, causes itself to happen again, happens again. --Douglas Adams ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
[Zope-dev] Re: SVN: Zope/branches/2.10/ Collector #2307: ObjectCopiedEvent not dispatched to sublocations.
On 20 Jun 2007, at 13:16 , Stefan H. Holek wrote: I took my cues from how ObjectModifiedEvent is handled. I figured copied and moved should be treated the same. Also, there is this comment in OFS/subscribers.py: # The following subscribers should really be defined in ZCML # but we don't have enough control over subscriber ordering for # that to work exactly right. # (Sometimes IItem comes before IObjectManager, sometimes after, # depending on some of Zope's classes.) # This code can be simplified when Zope is completely rid of # manage_afterAdd co, then IItem wouldn't be relevant anymore and we # could have a simple subscriber for IObjectManager that directly calls # dispatchToSublocations. Thanks, that explains it. I was just looking at the patch, not the whole module. ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] Re: SVN: Zope/branches/2.10/ Collector #2307: ObjectCopiedEvent not dispatched to sublocations.
This should of course have read: I took my cues from how *ObjectMovedEvent* is handled. On 20. Jun 2007, at 13:16, Stefan H. Holek wrote: I took my cues from how ObjectModifiedEvent is handled. I figured copied and moved should be treated the same. Also, there is this comment in OFS/subscribers.py: -- It doesn't necessarily do it in chronological order, though. --Douglas Adams ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )