[Zope-Checkins] SVN: Zope/trunk/ Stop using the Products packages as a data container for __ac_permissions__

Hanno Schlichting hannosch at hannosch.eu
Sat Jun 5 16:03:30 EDT 2010


Log message for revision 113170:
  Stop using the Products packages as a data container for __ac_permissions__
  

Changed:
  U   Zope/trunk/AC-vs-DTML-TODO.txt
  U   Zope/trunk/src/AccessControl/Permission.py
  U   Zope/trunk/src/AccessControl/Role.py

-=-
Modified: Zope/trunk/AC-vs-DTML-TODO.txt
===================================================================
--- Zope/trunk/AC-vs-DTML-TODO.txt	2010-06-05 19:58:00 UTC (rev 113169)
+++ Zope/trunk/AC-vs-DTML-TODO.txt	2010-06-05 20:03:30 UTC (rev 113170)
@@ -25,10 +25,6 @@
 
   * OFS - as a base class for User.BaseUserFolder
 
-  * Products (in registerPermissions using it as a data container for
-    ``__ac_permissions__``) - this should use a global inside the module
-    inside AccessControl.
-
   * App (MessageDialog, DTMLFile, ...) - all need to go - redoing the UI is
     hard. We probably need to move it into some other core part of Zope2, like
     the App package, which could serve as a general dumping ground for ZMI

Modified: Zope/trunk/src/AccessControl/Permission.py
===================================================================
--- Zope/trunk/src/AccessControl/Permission.py	2010-06-05 19:58:00 UTC (rev 113169)
+++ Zope/trunk/src/AccessControl/Permission.py	2010-06-05 20:03:30 UTC (rev 113170)
@@ -139,11 +139,11 @@
 
 
 _registeredPermissions = {}
+_ac_permissions = ()
 
 
 def getPermissions():
-    import Products
-    return getattr(Products, '__ac_permissions__', ())
+    return _ac_permissions
 
 
 def addPermission(perm, default_roles=('Manager', )):
@@ -151,9 +151,8 @@
         return
 
     entry = ((perm, (), default_roles), )
-    import Products
-    Products_permissions = getPermissions()
-    Products.__ac_permissions__ = Products_permissions + entry
+    global _ac_permissions
+    _ac_permissions = _ac_permissions + entry
     _registeredPermissions[perm] = 1
     mangled = pname(perm) # get mangled permission name
     if not hasattr(ApplicationDefaultPermissions, mangled):

Modified: Zope/trunk/src/AccessControl/Role.py
===================================================================
--- Zope/trunk/src/AccessControl/Role.py	2010-06-05 19:58:00 UTC (rev 113169)
+++ Zope/trunk/src/AccessControl/Role.py	2010-06-05 20:03:30 UTC (rev 113170)
@@ -600,7 +600,6 @@
 
     smallRolesWidget=selectedRoles=aclAChecked=aclPChecked=aclEChecked=''
     validRoles=valid_roles
-    #manage_rolesForm=manage_access
 
     def manage_editRoles(self, REQUEST, acl_type='A', acl_roles=[]):
         pass
@@ -609,16 +608,15 @@
         pass
 
     def possible_permissions(self):
-        d={}
-        Products_permissions = getPermissions()
-        for p in Products_permissions:
-            d[p[0]]=1
+        d = {}
+        permissions = getPermissions()
+        for p in permissions:
+            d[p[0]] = 1
         for p in self.ac_inherited_permissions(1):
-            d[p[0]]=1
+            d[p[0]] = 1
 
-        d=d.keys()
+        d = d.keys()
         d.sort()
-
         return d
 
 InitializeClass(RoleManager)



More information about the Zope-Checkins mailing list