Commit 6fa86f77 authored by Stefan H. Holek's avatar Stefan H. Holek

Merged trunk r73498:73499 into 2.9 branch.

Collector #2298: webdav.Resource.COPY and webdav.Resource.MOVE did
not send the expected copy/move events.
parents 9730698f 14f00911
...@@ -8,6 +8,9 @@ Zope Changes ...@@ -8,6 +8,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.app.event.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.app.event.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,12 +17,13 @@ $Id$ ...@@ -17,12 +17,13 @@ $Id$
import mimetypes import mimetypes
import sys import sys
import warnings
from urllib import unquote from urllib import unquote
import ExtensionClass import ExtensionClass
import Globals import Globals
from AccessControl import getSecurityManager from AccessControl import getSecurityManager
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
...@@ -39,7 +40,11 @@ from interfaces import IWriteLock ...@@ -39,7 +40,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.app.event.objectevent 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
...@@ -229,7 +234,7 @@ class Resource(ExtensionClass.Base, Lockable.LockableItem): ...@@ -229,7 +234,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:
...@@ -393,10 +398,14 @@ class Resource(ExtensionClass.Base, Lockable.LockableItem): ...@@ -393,10 +398,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)
...@@ -502,20 +511,52 @@ class Resource(ExtensionClass.Base, Lockable.LockableItem): ...@@ -502,20 +511,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