[CMF-checkins] SVN: CMF/branches/2.1/C - CMFCore.CMFBTreeFolder: CMFBTreeFolders could not be used as the

Jens Vagelpohl jens at dataflake.org
Fri Jun 8 11:08:30 EDT 2007


Log message for revision 76503:
  - CMFCore.CMFBTreeFolder: CMFBTreeFolders could not be used as the 
    toplevel /Members container.
    (http://www.zope.org/Collectors/CMF/441)
  

Changed:
  U   CMF/branches/2.1/CHANGES.txt
  U   CMF/branches/2.1/CMFCore/CMFBTreeFolder.py
  U   CMF/branches/2.1/CMFCore/tests/test_MembershipTool.py

-=-
Modified: CMF/branches/2.1/CHANGES.txt
===================================================================
--- CMF/branches/2.1/CHANGES.txt	2007-06-08 15:08:16 UTC (rev 76502)
+++ CMF/branches/2.1/CHANGES.txt	2007-06-08 15:08:29 UTC (rev 76503)
@@ -7,6 +7,10 @@
 
   Bug Fixes
 
+    - CMFCore.CMFBTreeFolder: CMFBTreeFolders could not be used as the
+      toplevel /Members container.
+      (http://www.zope.org/Collectors/CMF/441)
+
     - Pass 'object' through to TypeInformation objects' 'listActions'.
       (http://www.zope.org/Collectors/CMF/482)
       

Modified: CMF/branches/2.1/CMFCore/CMFBTreeFolder.py
===================================================================
--- CMF/branches/2.1/CMFCore/CMFBTreeFolder.py	2007-06-08 15:08:16 UTC (rev 76502)
+++ CMF/branches/2.1/CMFCore/CMFBTreeFolder.py	2007-06-08 15:08:29 UTC (rev 76503)
@@ -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/branches/2.1/CMFCore/tests/test_MembershipTool.py
===================================================================
--- CMF/branches/2.1/CMFCore/tests/test_MembershipTool.py	2007-06-08 15:08:16 UTC (rev 76502)
+++ CMF/branches/2.1/CMFCore/tests/test_MembershipTool.py	2007-06-08 15:08:29 UTC (rev 76503)
@@ -24,6 +24,7 @@
 from zope.component import getSiteManager
 from zope.testing.cleanup import cleanUp
 
+from Products.CMFCore.CMFBTreeFolder import CMFBTreeFolder
 from Products.CMFCore.MemberDataTool import MemberDataTool
 from Products.CMFCore.PortalFolder import PortalFolder
 from Products.CMFCore.interfaces import IMemberDataTool
@@ -115,6 +116,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