Commit 14f00911 authored by Stefan H. Holek's avatar Stefan H. Holek

Collector #2298: webdav.Resource.COPY and webdav.Resource.MOVE did

not send the expected copy/move events.

Note: Tests live in OFS.tests.
parent 0a6e6f19
...@@ -88,6 +88,9 @@ Zope Changes ...@@ -88,6 +88,9 @@ Zope Changes
Bugs Fixed Bugs Fixed
- Collector #2298: webdav.Resource.COPY and webdav.Resource.MOVE did
not send the expected copy/move events.
- Collector #2296: Fixed import of ZClass products, broken by removal - Collector #2296: Fixed import of ZClass products, broken by removal
of BBB support for pasting objects whose meta_type info was of BBB support for pasting objects whose meta_type info was
permission-free. permission-free.
......
<configure
xmlns="http://namespaces.zope.org/zope"
i18n_domain="extfile">
<!-- Item -->
<subscriber
handler=".testCopySupportEvents.objectAddedEvent"
for=".testCopySupportEvents.ITestItem
zope.app.container.interfaces.IObjectAddedEvent"
/>
<subscriber
handler=".testCopySupportEvents.objectCopiedEvent"
for=".testCopySupportEvents.ITestItem
zope.lifecycleevent.interfaces.IObjectCopiedEvent"
/>
<subscriber
handler=".testCopySupportEvents.objectMovedEvent"
for=".testCopySupportEvents.ITestItem
zope.app.container.interfaces.IObjectMovedEvent"
/>
<subscriber
handler=".testCopySupportEvents.objectRemovedEvent"
for=".testCopySupportEvents.ITestItem
zope.app.container.interfaces.IObjectRemovedEvent"
/>
<subscriber
handler=".testCopySupportEvents.objectWillBeAddedEvent"
for=".testCopySupportEvents.ITestItem
OFS.interfaces.IObjectWillBeAddedEvent"
/>
<subscriber
handler=".testCopySupportEvents.objectWillBeMovedEvent"
for=".testCopySupportEvents.ITestItem
OFS.interfaces.IObjectWillBeMovedEvent"
/>
<subscriber
handler=".testCopySupportEvents.objectWillBeRemovedEvent"
for=".testCopySupportEvents.ITestItem
OFS.interfaces.IObjectWillBeRemovedEvent"
/>
<subscriber
handler=".testCopySupportEvents.objectClonedEvent"
for=".testCopySupportEvents.ITestItem
OFS.interfaces.IObjectClonedEvent"
/>
<!-- Folder -->
<subscriber
handler=".testCopySupportEvents.objectAddedEvent"
for=".testCopySupportEvents.ITestFolder
zope.app.container.interfaces.IObjectAddedEvent"
/>
<subscriber
handler=".testCopySupportEvents.objectCopiedEvent"
for=".testCopySupportEvents.ITestFolder
zope.lifecycleevent.interfaces.IObjectCopiedEvent"
/>
<subscriber
handler=".testCopySupportEvents.objectMovedEvent"
for=".testCopySupportEvents.ITestFolder
zope.app.container.interfaces.IObjectMovedEvent"
/>
<subscriber
handler=".testCopySupportEvents.objectRemovedEvent"
for=".testCopySupportEvents.ITestFolder
zope.app.container.interfaces.IObjectRemovedEvent"
/>
<subscriber
handler=".testCopySupportEvents.containerModifiedEvent"
for=".testCopySupportEvents.ITestFolder
zope.app.container.interfaces.IContainerModifiedEvent"
/>
<subscriber
handler=".testCopySupportEvents.objectWillBeAddedEvent"
for=".testCopySupportEvents.ITestFolder
OFS.interfaces.IObjectWillBeAddedEvent"
/>
<subscriber
handler=".testCopySupportEvents.objectWillBeMovedEvent"
for=".testCopySupportEvents.ITestFolder
OFS.interfaces.IObjectWillBeMovedEvent"
/>
<subscriber
handler=".testCopySupportEvents.objectWillBeRemovedEvent"
for=".testCopySupportEvents.ITestFolder
OFS.interfaces.IObjectWillBeRemovedEvent"
/>
<subscriber
handler=".testCopySupportEvents.objectClonedEvent"
for=".testCopySupportEvents.ITestFolder
OFS.interfaces.IObjectClonedEvent"
/>
</configure>
This diff is collapsed.
...@@ -17,6 +17,7 @@ $Id$ ...@@ -17,6 +17,7 @@ $Id$
import mimetypes import mimetypes
import sys import sys
import warnings
from urllib import unquote from urllib import unquote
import ExtensionClass import ExtensionClass
...@@ -29,7 +30,7 @@ from AccessControl.Permissions import view as View ...@@ -29,7 +30,7 @@ from AccessControl.Permissions import view as View
from AccessControl.Permissions import webdav_lock_items from AccessControl.Permissions import webdav_lock_items
from AccessControl.Permissions import webdav_unlock_items from AccessControl.Permissions import webdav_unlock_items
from AccessControl.Permissions import webdav_access from AccessControl.Permissions import webdav_access
from Acquisition import aq_base from Acquisition import aq_base, aq_inner, aq_parent
from zExceptions import BadRequest, MethodNotAllowed from zExceptions import BadRequest, MethodNotAllowed
from zExceptions import Unauthorized, Forbidden, NotFound from zExceptions import Unauthorized, Forbidden, NotFound
from zope.interface import implements from zope.interface import implements
...@@ -46,7 +47,11 @@ from interfaces import IWriteLock ...@@ -46,7 +47,11 @@ from interfaces import IWriteLock
from WriteLockInterface import WriteLockInterface from WriteLockInterface import WriteLockInterface
from zope.event import notify from zope.event import notify
from zope.lifecycleevent import ObjectCopiedEvent
from zope.app.container.contained import ObjectMovedEvent
from zope.app.container.contained import notifyContainerModified
from OFS.event import ObjectClonedEvent from OFS.event import ObjectClonedEvent
from OFS.event import ObjectWillBeMovedEvent
import OFS.subscribers import OFS.subscribers
...@@ -230,7 +235,7 @@ class Resource(ExtensionClass.Base, Lockable.LockableItem): ...@@ -230,7 +235,7 @@ class Resource(ExtensionClass.Base, Lockable.LockableItem):
ifhdr = REQUEST.get_header('If', '') ifhdr = REQUEST.get_header('If', '')
url = urlfix(REQUEST['URL'], 'DELETE') url = urlfix(REQUEST['URL'], 'DELETE')
name = unquote(filter(None, url.split( '/')[-1])) name = unquote(filter(None, url.split( '/')[-1]))
parent = self.aq_parent parent = aq_parent(aq_inner(self))
# Lock checking # Lock checking
if Lockable.wl_isLocked(self): if Lockable.wl_isLocked(self):
if ifhdr: if ifhdr:
...@@ -396,10 +401,14 @@ class Resource(ExtensionClass.Base, Lockable.LockableItem): ...@@ -396,10 +401,14 @@ class Resource(ExtensionClass.Base, Lockable.LockableItem):
if depth=='0' and isDavCollection(ob): if depth=='0' and isDavCollection(ob):
for id in ob.objectIds(): for id in ob.objectIds():
ob._delObject(id) ob._delObject(id)
notify(ObjectCopiedEvent(ob, self))
if existing: if existing:
object=getattr(parent, name) object=getattr(parent, name)
self.dav__validate(object, 'DELETE', REQUEST) self.dav__validate(object, 'DELETE', REQUEST)
parent._delObject(name) parent._delObject(name)
parent._setObject(name, ob) parent._setObject(name, ob)
ob = parent._getOb(name) ob = parent._getOb(name)
ob._postCopy(parent, op=0) ob._postCopy(parent, op=0)
...@@ -505,20 +514,52 @@ class Resource(ExtensionClass.Base, Lockable.LockableItem): ...@@ -505,20 +514,52 @@ class Resource(ExtensionClass.Base, Lockable.LockableItem):
raise PreconditionFailed, 'Source is locked and no '\ raise PreconditionFailed, 'Source is locked and no '\
'condition was passed in.' 'condition was passed in.'
orig_container = aq_parent(aq_inner(self))
orig_id = self.getId()
self._notifyOfCopyTo(parent, op=1)
notify(ObjectWillBeMovedEvent(self, orig_container, orig_id,
parent, name))
# try to make ownership explicit so that it gets carried # try to make ownership explicit so that it gets carried
# along to the new location if needed. # along to the new location if needed.
self.manage_changeOwnershipType(explicit=1) self.manage_changeOwnershipType(explicit=1)
self._notifyOfCopyTo(parent, op=1) ob = self._getCopy(parent)
ob = aq_base(self._getCopy(parent))
self.aq_parent._delObject(absattr(self.id))
ob._setId(name) ob._setId(name)
try:
orig_container._delObject(orig_id, suppress_events=True)
except TypeError:
# BBB: removed in Zope 2.11
orig_container._delObject(orig_id)
warnings.warn(
"%s._delObject without suppress_events is deprecated "
"and will be removed in Zope 2.11." %
orig_container.__class__.__name__, DeprecationWarning)
if existing: if existing:
object=getattr(parent, name) object=getattr(parent, name)
self.dav__validate(object, 'DELETE', REQUEST) self.dav__validate(object, 'DELETE', REQUEST)
parent._delObject(name) parent._delObject(name)
parent._setObject(name, ob)
try:
parent._setObject(name, ob, set_owner=0, suppress_events=True)
except TypeError:
# BBB: removed in Zope 2.11
parent._setObject(name, ob, set_owner=0)
warnings.warn(
"%s._setObject without suppress_events is deprecated "
"and will be removed in Zope 2.11." %
parent.__class__.__name__, DeprecationWarning)
ob = parent._getOb(name) ob = parent._getOb(name)
notify(ObjectMovedEvent(ob, orig_container, orig_id, parent, name))
notifyContainerModified(orig_container)
if aq_base(orig_container) is not aq_base(parent):
notifyContainerModified(parent)
ob._postCopy(parent, op=1) ob._postCopy(parent, op=1)
# try to make ownership implicit if possible # try to make ownership implicit if possible
......
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