Commit ec9dd198 authored by Stefan H. Holek's avatar Stefan H. Holek

Collector #2307: ObjectCopiedEvent not dispatched to sublocations.

parent 46209156
...@@ -91,6 +91,8 @@ Zope Changes ...@@ -91,6 +91,8 @@ Zope Changes
Bugs Fixed Bugs Fixed
- Collector #2307: ObjectCopiedEvent not dispatched to sublocations.
- Collector #2298: webdav.Resource.COPY and webdav.Resource.MOVE did - Collector #2298: webdav.Resource.COPY and webdav.Resource.MOVE did
not send the expected copy/move events. not send the expected copy/move events.
......
...@@ -31,6 +31,7 @@ import zope.interface ...@@ -31,6 +31,7 @@ import zope.interface
import zope.location.interfaces import zope.location.interfaces
from zope.app.container.contained import dispatchToSublocations from zope.app.container.contained import dispatchToSublocations
from zope.app.container.interfaces import IObjectMovedEvent from zope.app.container.interfaces import IObjectMovedEvent
from zope.lifecycleevent.interfaces import IObjectCopiedEvent
deprecatedManageAddDeleteClasses = [] deprecatedManageAddDeleteClasses = []
...@@ -130,6 +131,14 @@ def dispatchObjectClonedEvent(ob, event): ...@@ -130,6 +131,14 @@ def dispatchObjectClonedEvent(ob, event):
if OFS.interfaces.IObjectManager.providedBy(ob): if OFS.interfaces.IObjectManager.providedBy(ob):
dispatchToSublocations(ob, event) dispatchToSublocations(ob, event)
@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): def callManageAfterAdd(ob, item, container):
"""Compatibility subscriber for manage_afterAdd. """Compatibility subscriber for manage_afterAdd.
......
...@@ -275,7 +275,7 @@ class TestCopySupportSublocation(EventTest): ...@@ -275,7 +275,7 @@ class TestCopySupportSublocation(EventTest):
# Test clone # Test clone
self.subfolder.manage_clone(self.folder.myfolder, 'myfolder') self.subfolder.manage_clone(self.folder.myfolder, 'myfolder')
self.assertEqual(eventlog.called(), self.assertEqual(eventlog.called(),
[#('mydoc', 'ObjectCopiedEvent'), [('mydoc', 'ObjectCopiedEvent'),
('myfolder', 'ObjectCopiedEvent'), ('myfolder', 'ObjectCopiedEvent'),
('mydoc', 'ObjectWillBeAddedEvent'), ('mydoc', 'ObjectWillBeAddedEvent'),
('myfolder', 'ObjectWillBeAddedEvent'), ('myfolder', 'ObjectWillBeAddedEvent'),
...@@ -291,7 +291,7 @@ class TestCopySupportSublocation(EventTest): ...@@ -291,7 +291,7 @@ class TestCopySupportSublocation(EventTest):
cb = self.folder.manage_copyObjects(['myfolder']) cb = self.folder.manage_copyObjects(['myfolder'])
self.subfolder.manage_pasteObjects(cb) self.subfolder.manage_pasteObjects(cb)
self.assertEqual(eventlog.called(), self.assertEqual(eventlog.called(),
[#('mydoc', 'ObjectCopiedEvent'), [('mydoc', 'ObjectCopiedEvent'),
('myfolder', 'ObjectCopiedEvent'), ('myfolder', 'ObjectCopiedEvent'),
('mydoc', 'ObjectWillBeAddedEvent'), ('mydoc', 'ObjectWillBeAddedEvent'),
('myfolder', 'ObjectWillBeAddedEvent'), ('myfolder', 'ObjectWillBeAddedEvent'),
...@@ -333,7 +333,7 @@ class TestCopySupportSublocation(EventTest): ...@@ -333,7 +333,7 @@ class TestCopySupportSublocation(EventTest):
req.environ['HTTP_DESTINATION'] = '%s/subfolder/myfolder' % self.folder.absolute_url() req.environ['HTTP_DESTINATION'] = '%s/subfolder/myfolder' % self.folder.absolute_url()
self.folder.myfolder.COPY(req, req.RESPONSE) self.folder.myfolder.COPY(req, req.RESPONSE)
self.assertEqual(eventlog.called(), self.assertEqual(eventlog.called(),
[#('mydoc', 'ObjectCopiedEvent'), [('mydoc', 'ObjectCopiedEvent'),
('myfolder', 'ObjectCopiedEvent'), ('myfolder', 'ObjectCopiedEvent'),
('mydoc', 'ObjectWillBeAddedEvent'), ('mydoc', 'ObjectWillBeAddedEvent'),
('myfolder', 'ObjectWillBeAddedEvent'), ('myfolder', 'ObjectWillBeAddedEvent'),
......
...@@ -16,4 +16,7 @@ ...@@ -16,4 +16,7 @@
<!-- dispatch IObjectClonedEvent with "top-down" semantics --> <!-- dispatch IObjectClonedEvent with "top-down" semantics -->
<subscriber handler="OFS.subscribers.dispatchObjectClonedEvent" /> <subscriber handler="OFS.subscribers.dispatchObjectClonedEvent" />
<!-- dispatch IObjectCopiedEvent with "top-down" semantics -->
<subscriber handler="OFS.subscribers.dispatchObjectCopiedEvent" />
</configure> </configure>
...@@ -57,6 +57,7 @@ printed events will be in their "natural" order:: ...@@ -57,6 +57,7 @@ printed events will be in their "natural" order::
>>> from zope.component.interfaces import IObjectEvent, IRegistrationEvent >>> from zope.component.interfaces import IObjectEvent, IRegistrationEvent
>>> from zope.app.container.interfaces import IObjectMovedEvent >>> from zope.app.container.interfaces import IObjectMovedEvent
>>> from zope.lifecycleevent.interfaces import IObjectCopiedEvent
>>> from OFS.interfaces import IObjectWillBeMovedEvent >>> from OFS.interfaces import IObjectWillBeMovedEvent
>>> from OFS.interfaces import IObjectClonedEvent >>> from OFS.interfaces import IObjectClonedEvent
>>> from OFS.interfaces import IItem >>> from OFS.interfaces import IItem
...@@ -64,6 +65,7 @@ printed events will be in their "natural" order:: ...@@ -64,6 +65,7 @@ printed events will be in their "natural" order::
... print event.__class__.__name__, object.getId() ... print event.__class__.__name__, object.getId()
>>> def printObjectEventExceptSome(object, event): >>> def printObjectEventExceptSome(object, event):
... if (IObjectMovedEvent.providedBy(event) or ... if (IObjectMovedEvent.providedBy(event) or
... IObjectCopiedEvent.providedBy(event) or
... IObjectWillBeMovedEvent.providedBy(event) or ... IObjectWillBeMovedEvent.providedBy(event) or
... IObjectClonedEvent.providedBy(event) or ... IObjectClonedEvent.providedBy(event) or
... IRegistrationEvent.providedBy(event)): ... IRegistrationEvent.providedBy(event)):
...@@ -72,6 +74,7 @@ printed events will be in their "natural" order:: ...@@ -72,6 +74,7 @@ printed events will be in their "natural" order::
>>> from zope.component import provideHandler >>> from zope.component import provideHandler
>>> provideHandler(printObjectEvent, (IItem, IObjectMovedEvent)) >>> provideHandler(printObjectEvent, (IItem, IObjectMovedEvent))
>>> provideHandler(printObjectEvent, (IItem, IObjectCopiedEvent))
>>> provideHandler(printObjectEvent, (IItem, IObjectWillBeMovedEvent)) >>> provideHandler(printObjectEvent, (IItem, IObjectWillBeMovedEvent))
>>> provideHandler(printObjectEvent, (IItem, IObjectClonedEvent)) >>> provideHandler(printObjectEvent, (IItem, IObjectClonedEvent))
>>> provideHandler(printObjectEventExceptSome, (None, IObjectEvent)) >>> provideHandler(printObjectEventExceptSome, (None, IObjectEvent))
...@@ -83,6 +86,7 @@ Finally we need to load the subscribers configuration:: ...@@ -83,6 +86,7 @@ Finally we need to load the subscribers configuration::
>>> zope.component.provideAdapter(OFS.subscribers.ObjectManagerSublocations) >>> zope.component.provideAdapter(OFS.subscribers.ObjectManagerSublocations)
>>> zope.component.provideHandler(OFS.subscribers.dispatchObjectWillBeMovedEvent) >>> zope.component.provideHandler(OFS.subscribers.dispatchObjectWillBeMovedEvent)
>>> zope.component.provideHandler(OFS.subscribers.dispatchObjectMovedEvent) >>> zope.component.provideHandler(OFS.subscribers.dispatchObjectMovedEvent)
>>> zope.component.provideHandler(OFS.subscribers.dispatchObjectCopiedEvent)
>>> zope.component.provideHandler(OFS.subscribers.dispatchObjectClonedEvent) >>> zope.component.provideHandler(OFS.subscribers.dispatchObjectClonedEvent)
We need at least one fake deprecated method to tell the compatibility We need at least one fake deprecated method to tell the compatibility
...@@ -133,6 +137,7 @@ Same thing for clone:: ...@@ -133,6 +137,7 @@ Same thing for clone::
>>> res = folder.manage_clone(folder.marine, 'tank') >>> res = folder.manage_clone(folder.marine, 'tank')
ObjectCopiedEvent tank ObjectCopiedEvent tank
ObjectCopiedEvent dog
ObjectWillBeAddedEvent tank ObjectWillBeAddedEvent tank
ObjectWillBeAddedEvent dog ObjectWillBeAddedEvent dog
ObjectAddedEvent tank ObjectAddedEvent tank
...@@ -282,6 +287,7 @@ Cloning a tree of objects:: ...@@ -282,6 +287,7 @@ Cloning a tree of objects::
>>> res = folder.manage_clone(folder.pluto, 'mickey') >>> res = folder.manage_clone(folder.pluto, 'mickey')
ObjectCopiedEvent mickey ObjectCopiedEvent mickey
ObjectCopiedEvent donald
ObjectWillBeAddedEvent mickey ObjectWillBeAddedEvent mickey
ObjectWillBeAddedEvent donald ObjectWillBeAddedEvent donald
ObjectAddedEvent mickey ObjectAddedEvent mickey
...@@ -414,6 +420,7 @@ Cloning a tree of objects:: ...@@ -414,6 +420,7 @@ Cloning a tree of objects::
>>> res = folder.manage_clone(folder.firefly, 'serenity') >>> res = folder.manage_clone(folder.firefly, 'serenity')
ObjectCopiedEvent serenity ObjectCopiedEvent serenity
ObjectCopiedEvent mel
ObjectWillBeAddedEvent serenity ObjectWillBeAddedEvent serenity
ObjectWillBeAddedEvent mel ObjectWillBeAddedEvent mel
ObjectAddedEvent serenity ObjectAddedEvent serenity
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment