[CMF-checkins] SVN: CMF/trunk/CMFCore/ CMFCore.PortalFolder._checkId() allows root doted prefixed name

Julien Anguenot ja at nuxeo.com
Thu Aug 18 12:22:47 EDT 2005


Log message for revision 37989:
  CMFCore.PortalFolder._checkId() allows root doted prefixed name
  object overrides.
  
  

Changed:
  U   CMF/trunk/CMFCore/PortalFolder.py
  U   CMF/trunk/CMFCore/tests/test_PortalFolder.py

-=-
Modified: CMF/trunk/CMFCore/PortalFolder.py
===================================================================
--- CMF/trunk/CMFCore/PortalFolder.py	2005-08-18 16:18:32 UTC (rev 37988)
+++ CMF/trunk/CMFCore/PortalFolder.py	2005-08-18 16:22:46 UTC (rev 37989)
@@ -107,9 +107,9 @@
     security = ClassSecurityInfo()
 
     description = ''
-    
+
     manage_options = ( Folder.manage_options +
-                       CMFCatalogAware.manage_options )  
+                       CMFCatalogAware.manage_options )
 
     def __init__( self, id, title='' ):
         self.id = id
@@ -397,7 +397,10 @@
             if ob is not None:
                 # If the portal root has a non-contentish object by this name,
                 # don't allow an override.
-                if hasattr(ob, id) and id not in ob.contentIds():
+                if (hasattr(ob, id) and
+                    id not in ob.contentIds() and
+                    # Allow root doted prefixed object name overrides
+                    not id.startswith('.')):
                     raise BadRequest('The id "%s" is reserved.' % id)
             # Don't allow ids used by Method Aliases.
             ti = self.getTypeInfo()

Modified: CMF/trunk/CMFCore/tests/test_PortalFolder.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_PortalFolder.py	2005-08-18 16:18:32 UTC (rev 37988)
+++ CMF/trunk/CMFCore/tests/test_PortalFolder.py	2005-08-18 16:22:46 UTC (rev 37989)
@@ -406,7 +406,24 @@
         test._setObject('foo', DummyContent('foo'))
         self.failIf(test.checkIdAvailable('foo'))
 
+    def test__checkId_starting_with_dot(self):
+        #
+        # doted prefixed names at the root of the portal can be overriden
+        #
 
+        # Create a .foo at the root
+        self.site._setObject('.foo', DummyContent('.foo'))
+
+        # Create a sub-folder
+        sub = self._makeOne('sub')
+
+        # It should be possible to create another .foo object in the
+        # sub-folder
+        acl_users = self.site._setObject('acl_users', DummyUserFolder())
+        newSecurityManager(None, acl_users.user_foo)
+
+        self.assert_(sub.checkIdAvailable('.foo'))
+
 class PortalFolderMoveTests(SecurityTest):
 
     def setUp(self):



More information about the CMF-checkins mailing list