[Zope-Checkins] SVN: Zope/trunk/ Collector #2307: ObjectCopiedEvent
not dispatched to sublocations.
Stefan H. Holek
stefan at epy.co.at
Mon Apr 9 12:38:09 EDT 2007
Log message for revision 74053:
Collector #2307: ObjectCopiedEvent not dispatched to sublocations.
Changed:
U Zope/trunk/doc/CHANGES.txt
U Zope/trunk/lib/python/OFS/subscribers.py
U Zope/trunk/lib/python/OFS/tests/testCopySupportEvents.py
U Zope/trunk/lib/python/Products/Five/event.zcml
U Zope/trunk/lib/python/Products/Five/tests/event.txt
-=-
Modified: Zope/trunk/doc/CHANGES.txt
===================================================================
--- Zope/trunk/doc/CHANGES.txt 2007-04-09 16:31:02 UTC (rev 74052)
+++ Zope/trunk/doc/CHANGES.txt 2007-04-09 16:38:09 UTC (rev 74053)
@@ -91,6 +91,8 @@
Bugs Fixed
+ - Collector #2307: ObjectCopiedEvent not dispatched to sublocations.
+
- Collector #2298: webdav.Resource.COPY and webdav.Resource.MOVE did
not send the expected copy/move events.
Modified: Zope/trunk/lib/python/OFS/subscribers.py
===================================================================
--- Zope/trunk/lib/python/OFS/subscribers.py 2007-04-09 16:31:02 UTC (rev 74052)
+++ Zope/trunk/lib/python/OFS/subscribers.py 2007-04-09 16:38:09 UTC (rev 74053)
@@ -31,6 +31,7 @@
import zope.location.interfaces
from zope.app.container.contained import dispatchToSublocations
from zope.app.container.interfaces import IObjectMovedEvent
+from zope.lifecycleevent.interfaces import IObjectCopiedEvent
deprecatedManageAddDeleteClasses = []
@@ -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)
+
def callManageAfterAdd(ob, item, container):
"""Compatibility subscriber for manage_afterAdd.
"""
Modified: Zope/trunk/lib/python/OFS/tests/testCopySupportEvents.py
===================================================================
--- Zope/trunk/lib/python/OFS/tests/testCopySupportEvents.py 2007-04-09 16:31:02 UTC (rev 74052)
+++ Zope/trunk/lib/python/OFS/tests/testCopySupportEvents.py 2007-04-09 16:38:09 UTC (rev 74053)
@@ -275,7 +275,7 @@
# Test clone
self.subfolder.manage_clone(self.folder.myfolder, 'myfolder')
self.assertEqual(eventlog.called(),
- [#('mydoc', 'ObjectCopiedEvent'),
+ [('mydoc', 'ObjectCopiedEvent'),
('myfolder', 'ObjectCopiedEvent'),
('mydoc', 'ObjectWillBeAddedEvent'),
('myfolder', 'ObjectWillBeAddedEvent'),
@@ -291,7 +291,7 @@
cb = self.folder.manage_copyObjects(['myfolder'])
self.subfolder.manage_pasteObjects(cb)
self.assertEqual(eventlog.called(),
- [#('mydoc', 'ObjectCopiedEvent'),
+ [('mydoc', 'ObjectCopiedEvent'),
('myfolder', 'ObjectCopiedEvent'),
('mydoc', 'ObjectWillBeAddedEvent'),
('myfolder', 'ObjectWillBeAddedEvent'),
@@ -333,7 +333,7 @@
req.environ['HTTP_DESTINATION'] = '%s/subfolder/myfolder' % self.folder.absolute_url()
self.folder.myfolder.COPY(req, req.RESPONSE)
self.assertEqual(eventlog.called(),
- [#('mydoc', 'ObjectCopiedEvent'),
+ [('mydoc', 'ObjectCopiedEvent'),
('myfolder', 'ObjectCopiedEvent'),
('mydoc', 'ObjectWillBeAddedEvent'),
('myfolder', 'ObjectWillBeAddedEvent'),
Modified: Zope/trunk/lib/python/Products/Five/event.zcml
===================================================================
--- Zope/trunk/lib/python/Products/Five/event.zcml 2007-04-09 16:31:02 UTC (rev 74052)
+++ Zope/trunk/lib/python/Products/Five/event.zcml 2007-04-09 16:38:09 UTC (rev 74053)
@@ -16,4 +16,7 @@
<!-- dispatch IObjectClonedEvent with "top-down" semantics -->
<subscriber handler="OFS.subscribers.dispatchObjectClonedEvent" />
+ <!-- dispatch IObjectCopiedEvent with "top-down" semantics -->
+ <subscriber handler="OFS.subscribers.dispatchObjectCopiedEvent" />
+
</configure>
Modified: Zope/trunk/lib/python/Products/Five/tests/event.txt
===================================================================
--- Zope/trunk/lib/python/Products/Five/tests/event.txt 2007-04-09 16:31:02 UTC (rev 74052)
+++ Zope/trunk/lib/python/Products/Five/tests/event.txt 2007-04-09 16:38:09 UTC (rev 74053)
@@ -57,6 +57,7 @@
>>> from zope.component.interfaces import IObjectEvent, IRegistrationEvent
>>> from zope.app.container.interfaces import IObjectMovedEvent
+ >>> from zope.lifecycleevent.interfaces import IObjectCopiedEvent
>>> from OFS.interfaces import IObjectWillBeMovedEvent
>>> from OFS.interfaces import IObjectClonedEvent
>>> from OFS.interfaces import IItem
@@ -64,6 +65,7 @@
... print event.__class__.__name__, object.getId()
>>> def printObjectEventExceptSome(object, event):
... if (IObjectMovedEvent.providedBy(event) or
+ ... IObjectCopiedEvent.providedBy(event) or
... IObjectWillBeMovedEvent.providedBy(event) or
... IObjectClonedEvent.providedBy(event) or
... IRegistrationEvent.providedBy(event)):
@@ -72,6 +74,7 @@
>>> from zope.component import provideHandler
>>> provideHandler(printObjectEvent, (IItem, IObjectMovedEvent))
+ >>> provideHandler(printObjectEvent, (IItem, IObjectCopiedEvent))
>>> provideHandler(printObjectEvent, (IItem, IObjectWillBeMovedEvent))
>>> provideHandler(printObjectEvent, (IItem, IObjectClonedEvent))
>>> provideHandler(printObjectEventExceptSome, (None, IObjectEvent))
@@ -83,6 +86,7 @@
>>> zope.component.provideAdapter(OFS.subscribers.ObjectManagerSublocations)
>>> zope.component.provideHandler(OFS.subscribers.dispatchObjectWillBeMovedEvent)
>>> zope.component.provideHandler(OFS.subscribers.dispatchObjectMovedEvent)
+ >>> zope.component.provideHandler(OFS.subscribers.dispatchObjectCopiedEvent)
>>> zope.component.provideHandler(OFS.subscribers.dispatchObjectClonedEvent)
We need at least one fake deprecated method to tell the compatibility
@@ -133,6 +137,7 @@
>>> res = folder.manage_clone(folder.marine, 'tank')
ObjectCopiedEvent tank
+ ObjectCopiedEvent dog
ObjectWillBeAddedEvent tank
ObjectWillBeAddedEvent dog
ObjectAddedEvent tank
@@ -282,6 +287,7 @@
>>> res = folder.manage_clone(folder.pluto, 'mickey')
ObjectCopiedEvent mickey
+ ObjectCopiedEvent donald
ObjectWillBeAddedEvent mickey
ObjectWillBeAddedEvent donald
ObjectAddedEvent mickey
@@ -414,6 +420,7 @@
>>> res = folder.manage_clone(folder.firefly, 'serenity')
ObjectCopiedEvent serenity
+ ObjectCopiedEvent mel
ObjectWillBeAddedEvent serenity
ObjectWillBeAddedEvent mel
ObjectAddedEvent serenity
More information about the Zope-Checkins
mailing list