[CMF-checkins] SVN: CMF/branches/2.1/CMFCore/ - User folders not
supporting the userFolderDelUsers API, such as PAS,
Jens Vagelpohl
jens at dataflake.org
Sat Jun 2 07:33:15 EDT 2007
Log message for revision 76152:
- 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/2.1/CMFCore/MembershipTool.py
U CMF/branches/2.1/CMFCore/tests/test_MembershipTool.py
-=-
Modified: CMF/branches/2.1/CMFCore/MembershipTool.py
===================================================================
--- CMF/branches/2.1/CMFCore/MembershipTool.py 2007-06-02 11:30:35 UTC (rev 76151)
+++ CMF/branches/2.1/CMFCore/MembershipTool.py 2007-06-02 11:33:14 UTC (rev 76152)
@@ -510,7 +510,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/2.1/CMFCore/tests/test_MembershipTool.py
===================================================================
--- CMF/branches/2.1/CMFCore/tests/test_MembershipTool.py 2007-06-02 11:30:35 UTC (rev 76151)
+++ CMF/branches/2.1/CMFCore/tests/test_MembershipTool.py 2007-06-02 11:33:14 UTC (rev 76152)
@@ -165,6 +165,40 @@
cleanUp()
+ 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