[Zope-Checkins] SVN: Zope/branches/2.9/lib/python/ Made sure
WebDAV.COPY sends an ObjectClonedEvent.
Stefan H. Holek
stefan at epy.co.at
Tue Aug 22 06:05:33 EDT 2006
Log message for revision 69723:
Made sure WebDAV.COPY sends an ObjectClonedEvent.
Fixes http://www.zope.org/Collectors/Zope/2169
Changed:
U Zope/branches/2.9/lib/python/OFS/tests/testCopySupportHooks.py
U Zope/branches/2.9/lib/python/webdav/Resource.py
-=-
Modified: Zope/branches/2.9/lib/python/OFS/tests/testCopySupportHooks.py
===================================================================
--- Zope/branches/2.9/lib/python/OFS/tests/testCopySupportHooks.py 2006-08-21 21:03:15 UTC (rev 69722)
+++ Zope/branches/2.9/lib/python/OFS/tests/testCopySupportHooks.py 2006-08-22 10:05:31 UTC (rev 69723)
@@ -159,7 +159,16 @@
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 @@
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,7 +244,18 @@
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()
suite.addTest(unittest.makeSuite(TestCopySupport))
Modified: Zope/branches/2.9/lib/python/webdav/Resource.py
===================================================================
--- Zope/branches/2.9/lib/python/webdav/Resource.py 2006-08-21 21:03:15 UTC (rev 69722)
+++ Zope/branches/2.9/lib/python/webdav/Resource.py 2006-08-22 10:05:31 UTC (rev 69723)
@@ -38,7 +38,11 @@
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):
"""The Resource mixin class provides basic WebDAV support for
@@ -396,7 +400,11 @@
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()
More information about the Zope-Checkins
mailing list