[CMF-checkins] SVN: CMF/branches/1.6/C - User folders not supporting the userFolderDelUsers API, such as PAS,

Jens Vagelpohl jens at dataflake.org
Sat Jun 2 07:27:02 EDT 2007


Log message for revision 76149:
  - User folders not supporting the userFolderDelUsers API, such as PAS,
    would raise an unhelpful error when members were deleted using the
    portal_membership tool.
    (http://www.zope.org/Collectors/CMF/481)
  

Changed:
  U   CMF/branches/1.6/CHANGES.txt
  U   CMF/branches/1.6/CMFCore/MembershipTool.py
  U   CMF/branches/1.6/CMFCore/tests/test_MembershipTool.py

-=-
Modified: CMF/branches/1.6/CHANGES.txt
===================================================================
--- CMF/branches/1.6/CHANGES.txt	2007-06-02 11:05:48 UTC (rev 76148)
+++ CMF/branches/1.6/CHANGES.txt	2007-06-02 11:27:02 UTC (rev 76149)
@@ -2,6 +2,11 @@
 
   Bug Fixes
 
+    - User folders not supporting the userFolderDelUsers API, such as PAS,
+      would raise an unhelpful error when members were deleted using the
+      portal_membership tool.
+      (http://www.zope.org/Collectors/CMF/481)
+
     - Backported test fix from 2.1 branch which suppresses race conditions
       in date-based topic criteria tests.
 

Modified: CMF/branches/1.6/CMFCore/MembershipTool.py
===================================================================
--- CMF/branches/1.6/CMFCore/MembershipTool.py	2007-06-02 11:05:48 UTC (rev 76148)
+++ CMF/branches/1.6/CMFCore/MembershipTool.py	2007-06-02 11:27:02 UTC (rev 76149)
@@ -494,7 +494,7 @@
                     member_ids.remove(member_id)
             try:
                 acl_users.userFolderDelUsers(member_ids)
-            except (NotImplementedError, 'NotImplemented'):
+            except (AttributeError, NotImplementedError, 'NotImplemented'):
                 raise NotImplementedError('The underlying User Folder '
                                          'doesn\'t support deleting members.')
         else:

Modified: CMF/branches/1.6/CMFCore/tests/test_MembershipTool.py
===================================================================
--- CMF/branches/1.6/CMFCore/tests/test_MembershipTool.py	2007-06-02 11:05:48 UTC (rev 76148)
+++ CMF/branches/1.6/CMFCore/tests/test_MembershipTool.py	2007-06-02 11:27:02 UTC (rev 76149)
@@ -141,6 +141,40 @@
         self.failIf( mdtool._members.has_key('user_foo') )
         self.failIf( hasattr(members.aq_self, 'user_foo') )
 
+    def test_deleteMembersUnsupported(self):
+        # Quite a few user folders do not support the deletion API
+        # http://www.zope.org/Collectors/CMF/481
+        # Make sure we get the right exception
+        site = self._makeSite()
+        mtool = site.portal_membership
+        members = site._setObject( 'Members', PortalFolder('Members') )
+        acl_users = site._setObject( 'acl_users', DummyUserFolder() )
+        utool = site._setObject( 'portal_url', DummyTool() )
+        wtool = site._setObject( 'portal_workflow', DummyTool() )
+        mdtool = site._setObject( 'portal_memberdata', MemberDataTool() )
+        newSecurityManager(None, acl_users.all_powerful_Oz)
+
+        self.assertEqual( acl_users.getUserById('user_foo'),
+                          acl_users.user_foo )
+        mtool.createMemberArea('user_foo')
+        self.failUnless( hasattr(members.aq_self, 'user_foo') )
+        mdtool.registerMemberData('Dummy', 'user_foo')
+        self.failUnless( mdtool._members.has_key('user_foo') )
+
+        # Fake an incompatible user folder by deleting the class method
+        deletion_method = DummyUserFolder.userFolderDelUsers
+        del DummyUserFolder.userFolderDelUsers
+        self.assertRaises( NotImplementedError
+                         , mtool.deleteMembers
+                         , ('user_foo',)
+                         )
+        self.failUnless( acl_users.getUserById('user_foo', None) )
+        self.failUnless( mdtool._members.has_key('user_foo') )
+        self.failUnless( hasattr(members.aq_self, 'user_foo') )
+
+        # Cleanup
+        DummyUserFolder.userFolderDelUsers = deletion_method
+
     def test_getMemberById_nonesuch(self):
         INVALID_USER_ID = 'nonesuch'
 



More information about the CMF-checkins mailing list