[Zope-Checkins] SVN: Zope/branches/Zope-2_8-branch/ Merged r40403 from 2.9 branch:

Florent Guillaume fg at nuxeo.com
Tue Nov 29 10:05:15 EST 2005


Log message for revision 40406:
  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/branches/Zope-2_8-branch/doc/CHANGES.txt
  U   Zope/branches/Zope-2_8-branch/lib/python/AccessControl/SecurityInfo.py
  U   Zope/branches/Zope-2_8-branch/lib/python/AccessControl/tests/testClassSecurityInfo.py

-=-
Modified: Zope/branches/Zope-2_8-branch/doc/CHANGES.txt
===================================================================
--- Zope/branches/Zope-2_8-branch/doc/CHANGES.txt	2005-11-29 15:03:04 UTC (rev 40405)
+++ Zope/branches/Zope-2_8-branch/doc/CHANGES.txt	2005-11-29 15:05:15 UTC (rev 40406)
@@ -26,6 +26,10 @@
 
     Bugs Fixed
 
+      - AccessControl.SecurityInfo: Fixed problem with
+        setPermissionDefault when the permission wasn't used anywhere
+        else in the class to protect methods.
+
       - Collector #1957:  Made ZPublisher.HTTPResponse._error_html
         return conformant XHTML.
 

Modified: Zope/branches/Zope-2_8-branch/lib/python/AccessControl/SecurityInfo.py
===================================================================
--- Zope/branches/Zope-2_8-branch/lib/python/AccessControl/SecurityInfo.py	2005-11-29 15:03:04 UTC (rev 40405)
+++ Zope/branches/Zope-2_8-branch/lib/python/AccessControl/SecurityInfo.py	2005-11-29 15:05:15 UTC (rev 40406)
@@ -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/Zope-2_8-branch/lib/python/AccessControl/tests/testClassSecurityInfo.py
===================================================================
--- Zope/branches/Zope-2_8-branch/lib/python/AccessControl/tests/testClassSecurityInfo.py	2005-11-29 15:03:04 UTC (rev 40405)
+++ Zope/branches/Zope-2_8-branch/lib/python/AccessControl/tests/testClassSecurityInfo.py	2005-11-29 15:05:15 UTC (rev 40406)
@@ -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