[Zope-Checkins] SVN: Zope/trunk/ - Collector #2073: fixed misbehaviour of OFS.Owned.changeOwnership

Andreas Jung andreas at andreas-jung.com
Sat Jun 10 10:05:03 EDT 2006


Log message for revision 68569:
        - Collector #2073: fixed misbehaviour of OFS.Owned.changeOwnership
  

Changed:
  U   Zope/trunk/doc/CHANGES.txt
  U   Zope/trunk/lib/python/AccessControl/Owned.py
  A   Zope/trunk/lib/python/AccessControl/tests/testChownRecursive.py

-=-
Modified: Zope/trunk/doc/CHANGES.txt
===================================================================
--- Zope/trunk/doc/CHANGES.txt	2006-06-10 13:52:14 UTC (rev 68568)
+++ Zope/trunk/doc/CHANGES.txt	2006-06-10 14:05:01 UTC (rev 68569)
@@ -27,5 +27,6 @@
       - Collector #2122: fixed missing is_proxying_match definition
         in ZServer/HTTPServer
 
-      - Collector 2077: fixed problem with ACTUAL_URL and SiteRoot
+      - Collector #2077: fixed problem with ACTUAL_URL and SiteRoot
 
+      - Collector #2073: fixed misbehaviour of OFS.Owned.changeOwnership

Modified: Zope/trunk/lib/python/AccessControl/Owned.py
===================================================================
--- Zope/trunk/lib/python/AccessControl/Owned.py	2006-06-10 13:52:14 UTC (rev 68568)
+++ Zope/trunk/lib/python/AccessControl/Owned.py	2006-06-10 14:05:01 UTC (rev 68569)
@@ -153,8 +153,9 @@
         new=ownerInfo(user)
         if new is None: return # Special user!
         old = self.getOwnerTuple()
-        if old==new: return
-        if old is UnownableOwner: return
+        if not recursive:
+            if old==new: return
+            if old is UnownableOwner: return
 
         for child in self.objectValues():
             if recursive:

Added: Zope/trunk/lib/python/AccessControl/tests/testChownRecursive.py
===================================================================
--- Zope/trunk/lib/python/AccessControl/tests/testChownRecursive.py	2006-06-10 13:52:14 UTC (rev 68568)
+++ Zope/trunk/lib/python/AccessControl/tests/testChownRecursive.py	2006-06-10 14:05:01 UTC (rev 68569)
@@ -0,0 +1,78 @@
+# vim: ts=4 expandtab :
+##############################################################################
+#
+# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Skeleton ZopeTestCase
+
+$Id: testSkeleton.py 30245 2005-05-05 09:50:09Z shh $
+"""
+
+import os, sys
+if __name__ == '__main__':
+    execfile(os.path.join(sys.path[0], 'framework.py'))
+
+from Testing import ZopeTestCase
+
+#ZopeTestCase.installProduct('SomeProduct')
+
+
+class TestRecursiveChangeOwnership(ZopeTestCase.ZopeTestCase):
+    user_name2 = "dumdidum"
+    user_pass2 = "dumdidum"
+    
+    def afterSetUp(self):
+##        self.folder.changeOwnership(ZopeTestCase.user_name)
+        
+        # need a second user
+        ufld = self.folder['acl_users']
+        ufld.userFolderAddUser(self.user_name2, self.user_pass2, [], [])
+
+        # remember user objects
+        # is the __of__() call correct? is it needed? without it ownerInfo in Owned.py throws
+        # an AttributeError ...
+        self.user1 = self.folder['acl_users'].getUser(ZopeTestCase.user_name).__of__(self.folder)
+        self.user2 = self.folder['acl_users'].getUser(self.user_name2).__of__(self.folder)
+
+        self.folder.changeOwnership(self.user1)
+
+        # need some objects owned by second user
+        # beneath self.folder
+        self.folder.manage_addFile("testfile")
+        self.file = self.folder["testfile"]
+        self.file.changeOwnership(self.user2)
+
+    def testRecursiveChangeOwnership(self):
+        # ensure folder is owned by user1
+        owner = self.folder.getOwnerTuple()[1]
+        self.assertEqual(owner, ZopeTestCase.user_name)
+        
+        # ensure file is owned by user2
+        owner = self.file.getOwnerTuple()[1]
+        self.assertEqual(owner, self.user_name2)
+        
+        self.folder.changeOwnership(self.user1, recursive=1)
+        
+        # ensure file's ownership has changed now to user1
+        owner = self.file.getOwnerTuple()[1]
+        self.assertEqual(owner, ZopeTestCase.user_name)
+        
+
+
+def test_suite():
+    from unittest import TestSuite, makeSuite
+    suite = TestSuite()
+    suite.addTest(makeSuite(TestRecursiveChangeOwnership))
+    return suite
+
+if __name__ == '__main__':
+    framework()
+



More information about the Zope-Checkins mailing list