Log message for revision 40403:
  Fixed problem with security.setPermissionDefault when the permission
  wasn't used anywhere else in the class to protect methods.
  

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

-=-
Modified: Zope/branches/2.9/lib/python/AccessControl/SecurityInfo.py
===================================================================
--- Zope/branches/2.9/lib/python/AccessControl/SecurityInfo.py  2005-11-29 
14:30:14 UTC (rev 40402)
+++ Zope/branches/2.9/lib/python/AccessControl/SecurityInfo.py  2005-11-29 
14:54:15 UTC (rev 40403)
@@ -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/branches/2.9/lib/python/AccessControl/tests/testClassSecurityInfo.py
===================================================================
--- Zope/branches/2.9/lib/python/AccessControl/tests/testClassSecurityInfo.py   
2005-11-29 14:30:14 UTC (rev 40402)
+++ Zope/branches/2.9/lib/python/AccessControl/tests/testClassSecurityInfo.py   
2005-11-29 14:54:15 UTC (rev 40403)
@@ -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))

_______________________________________________
Zope-Checkins maillist  -  Zope-Checkins@zope.org
http://mail.zope.org/mailman/listinfo/zope-checkins

Reply via email to