[CMF-checkins] SVN: CMF/trunk/CMFCore/ - CMFCore.CMFBTreeFolder:
CMFBTreeFolders could not be used as the
Jens Vagelpohl
jens at dataflake.org
Fri Jun 8 11:08:44 EDT 2007
Log message for revision 76504:
- CMFCore.CMFBTreeFolder: CMFBTreeFolders could not be used as the
toplevel /Members container.
(http://www.zope.org/Collectors/CMF/441)
Changed:
U CMF/trunk/CMFCore/CMFBTreeFolder.py
U CMF/trunk/CMFCore/tests/test_MembershipTool.py
-=-
Modified: CMF/trunk/CMFCore/CMFBTreeFolder.py
===================================================================
--- CMF/trunk/CMFCore/CMFBTreeFolder.py 2007-06-08 15:08:29 UTC (rev 76503)
+++ CMF/trunk/CMFCore/CMFBTreeFolder.py 2007-06-08 15:08:44 UTC (rev 76504)
@@ -21,6 +21,8 @@
from Products.BTreeFolder2.BTreeFolder2 import BTreeFolder2Base
from zope.component.factory import Factory
+from permissions import AddPortalFolders
+from PortalFolder import PortalFolder
from PortalFolder import PortalFolderBase
@@ -51,6 +53,16 @@
PortalFolderBase._checkId(self, id, allow_dup)
BTreeFolder2Base._checkId(self, id, allow_dup)
+ security.declareProtected(AddPortalFolders, 'manage_addPortalFolder')
+ def manage_addPortalFolder(self, id, title='', REQUEST=None):
+ """Add a new PortalFolder object with id *id*.
+ """
+ ob = PortalFolder(id, title)
+ self._setObject(id, ob)
+ if REQUEST is not None:
+ return self.folder_contents( # XXX: ick!
+ self, REQUEST, portal_status_message="Folder added")
+
InitializeClass(CMFBTreeFolder)
CMFBTreeFolderFactory = Factory(CMFBTreeFolder)
Modified: CMF/trunk/CMFCore/tests/test_MembershipTool.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_MembershipTool.py 2007-06-08 15:08:29 UTC (rev 76503)
+++ CMF/trunk/CMFCore/tests/test_MembershipTool.py 2007-06-08 15:08:44 UTC (rev 76504)
@@ -24,6 +24,7 @@
from zope.interface.verify import verifyClass
from zope.testing.cleanup import cleanUp
+from Products.CMFCore.CMFBTreeFolder import CMFBTreeFolder
from Products.CMFCore.interfaces import IMemberDataTool
from Products.CMFCore.interfaces import ISiteRoot
from Products.CMFCore.MemberDataTool import MemberDataTool
@@ -102,6 +103,39 @@
'CMF Collector issue #162 (LocalRoles broken): %s'
% str( f.get_local_roles() ) )
+ def test_createMemberAreaCMFBTreeFolder(self):
+ # Test member area creation if the toplevel "Members" folder is
+ # a CMFBTreeFolder (http://www.zope.org/Collectors/CMF/441
+ site = self._makeSite()
+ mtool = site.portal_membership
+ members = site._setObject( 'Members', CMFBTreeFolder('Members') )
+ acl_users = site._setObject( 'acl_users', DummyUserFolder() )
+ wtool = site._setObject( 'portal_workflow', DummyTool() )
+
+ # permission
+ mtool.createMemberArea('user_foo')
+ self.failIf( hasattr(members.aq_self, 'user_foo') )
+ newSecurityManager(None, acl_users.user_bar)
+ mtool.createMemberArea('user_foo')
+ self.failIf( hasattr(members.aq_self, 'user_foo') )
+ newSecurityManager(None, acl_users.user_foo)
+ mtool.setMemberareaCreationFlag()
+ mtool.createMemberArea('user_foo')
+ self.failIf( hasattr(members.aq_self, 'user_foo') )
+ newSecurityManager(None, acl_users.all_powerful_Oz)
+ mtool.setMemberareaCreationFlag()
+ mtool.createMemberArea('user_foo')
+ self.failUnless( hasattr(members.aq_self, 'user_foo') )
+
+ # default content
+ f = members.user_foo
+ ownership = acl_users.user_foo
+ localroles = ( ( 'user_foo', ('Owner',) ), )
+ self.assertEqual( f.getOwner(), ownership )
+ self.assertEqual( f.get_local_roles(), localroles,
+ 'CMF Collector issue #162 (LocalRoles broken): %s'
+ % str( f.get_local_roles() ) )
+
def test_createMemberArea_chained(self):
LOCAL_USER_ID = 'user_foo'
NONLOCAL_USER_ID = 'user_bar'
More information about the CMF-checkins
mailing list