[Zope-Checkins] SVN: Zope/trunk/lib/python/AccessControl/ Merged r40403 from 2.9 branch:

Florent Guillaume fg at nuxeo.com
Tue Nov 29 09:56:48 EST 2005


Log message for revision 40404:
  Merged r40403 from 2.9 branch:
  Fixed problem with security.setPermissionDefault when the permission
  wasn't used anywhere else in the class to protect methods.
  

Changed:
  U   Zope/trunk/lib/python/AccessControl/SecurityInfo.py
  U   Zope/trunk/lib/python/AccessControl/tests/testClassSecurityInfo.py

-=-
Modified: Zope/trunk/lib/python/AccessControl/SecurityInfo.py
===================================================================
--- Zope/trunk/lib/python/AccessControl/SecurityInfo.py	2005-11-29 14:54:15 UTC (rev 40403)
+++ Zope/trunk/lib/python/AccessControl/SecurityInfo.py	2005-11-29 14:56:48 UTC (rev 40404)
@@ -180,6 +180,10 @@
             else:
                 entry = (permission_name, tuple(names))
             __ac_permissions__.append(entry)
+        for permission_name, roles in self.roles.items():
+            if permission_name not in ac_permissions:
+                entry = (permission_name, (), tuple(roles.keys()))
+                __ac_permissions__.append(entry)
         setattr(classobj, '__ac_permissions__', tuple(__ac_permissions__))
 
         # Take care of default attribute access policy

Modified: Zope/trunk/lib/python/AccessControl/tests/testClassSecurityInfo.py
===================================================================
--- Zope/trunk/lib/python/AccessControl/tests/testClassSecurityInfo.py	2005-11-29 14:54:15 UTC (rev 40403)
+++ Zope/trunk/lib/python/AccessControl/tests/testClassSecurityInfo.py	2005-11-29 14:56:48 UTC (rev 40404)
@@ -44,6 +44,8 @@
 
             security = ClassSecurityInfo()
 
+            security.setPermissionDefault('Make food', ('Chef',))
+
             security.setPermissionDefault(
                 'Test permission',
                 ('Manager', 'Role A', 'Role B', 'Role C')
@@ -68,7 +70,12 @@
         for item in ('Manager', 'Role A', 'Role B', 'Role C'):
             self.failUnless(item in imPermissionRole)
 
+        # Make sure that a permission defined without accompanying method
+        # is still reflected in __ac_permissions__
+        self.assertEquals([t for t in Test.__ac_permissions__ if not t[1]],
+                          [('Make food', (), ('Chef',))])
 
+
 def test_suite():
     suite = unittest.TestSuite()
     suite.addTest(unittest.makeSuite(ClassSecurityInfoTests))



More information about the Zope-Checkins mailing list