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

Made sure WebDAV.COPY sends an ObjectClonedEvent.

Fixes http://www.zope.org/Collectors/Zope/2169
parent bad63b39
......@@ -159,6 +159,15 @@ class TestCopySupport(HookTest):
self.assertEqual(old.order(), (0, 0, 1)) # del
self.assertEqual(self.subfolder.mydoc.order(), (1, 0, 0)) # add
def test_7_DELETE(self):
# Test webdav DELETE
req = self.app.REQUEST
req['URL'] = '%s/mydoc' % self.folder.absolute_url()
old = self.folder.mydoc
self.folder.mydoc.DELETE(req, req.RESPONSE)
self.assertEqual(req.RESPONSE.getStatus(), 204)
self.assertEqual(old.order(), (0, 0, 1)) # del
class TestCopySupportSublocation(HookTest):
'''Tests the order in which the add/clone/del hooks are called'''
......@@ -210,6 +219,9 @@ class TestCopySupportSublocation(HookTest):
def test_5_COPY(self):
# Test webdav COPY
#
# See http://www.zope.org/Collectors/Zope/2169
#
req = self.app.REQUEST
req.environ['HTTP_DEPTH'] = 'infinity'
req.environ['HTTP_DESTINATION'] = '%s/subfolder/yourfolder' % self.folder.absolute_url()
......@@ -232,6 +244,17 @@ class TestCopySupportSublocation(HookTest):
self.assertEqual(olddoc.order(), (0, 0, 1)) # del
self.assertEqual(self.subfolder.yourfolder.mydoc.order(), (1, 0, 0)) # add
def test_7_DELETE(self):
# Test webdav DELETE
req = self.app.REQUEST
req['URL'] = '%s/myfolder' % self.folder.absolute_url()
oldfolder = self.folder.myfolder
olddoc = self.folder.myfolder.mydoc
self.folder.myfolder.DELETE(req, req.RESPONSE)
self.assertEqual(req.RESPONSE.getStatus(), 204)
self.assertEqual(oldfolder.order(), (0, 0, 1)) # del
self.assertEqual(olddoc.order(), (0, 0, 1)) # del
def test_suite():
suite = unittest.TestSuite()
......
......@@ -38,6 +38,10 @@ from interfaces import IDAVResource
from interfaces import IWriteLock
from WriteLockInterface import WriteLockInterface
from zope.event import notify
from OFS.event import ObjectClonedEvent
import OFS.subscribers
class Resource(ExtensionClass.Base, Lockable.LockableItem):
......@@ -396,7 +400,11 @@ class Resource(ExtensionClass.Base, Lockable.LockableItem):
parent._setObject(name, ob)
ob = parent._getOb(name)
ob._postCopy(parent, op=0)
ob.manage_afterClone(ob)
OFS.subscribers.compatibilityCall('manage_afterClone', ob, ob)
notify(ObjectClonedEvent(ob))
# We remove any locks from the copied object because webdav clients
# don't track the lock status and the lock token for copied resources
ob.wl_clearLocks()
......
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