[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Security - AttributePrincipalPermissionManager.py:1.1.2.6 AttributePrincipalRoleManager.py:1.1.2.6 AttributeRolePermissionManager.py:1.1.2.11 security.zcml:1.1.2.7

Steve Alexander steve@cat-box.net
Sun, 26 May 2002 12:10:28 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/App/Security
In directory cvs.zope.org:/tmp/cvs-serv3979/lib/python/Zope/App/Security

Modified Files:
      Tag: Zope-3x-branch
	AttributePrincipalPermissionManager.py 
	AttributePrincipalRoleManager.py 
	AttributeRolePermissionManager.py security.zcml 
Log Message:
Changed MementoBag to Annotations as per collector issue 66
http://collector.zope.org/Zope3-dev/66

Note that this will break pre-existing __memobag__ attributes in
persistent objects.


=== Zope3/lib/python/Zope/App/Security/AttributePrincipalPermissionManager.py 1.1.2.5 => 1.1.2.6 ===
 
 from Zope.ComponentArchitecture import getAdapter
-from Zope.App.OFS.Memento.IMementoBag import IMementoBag
+from Zope.App.OFS.Annotation.IAnnotations import IAnnotations
 from Zope.App.Security.IPrincipalPermissionManager \
      import IPrincipalPermissionManager
 from Zope.App.Security.LocalSecurityMap import LocalSecurityMap
 from Zope.App.Security.Settings import Allow, Deny, Unset
 
-memo_key = 'Zope.App.Security.AttributePrincipalPermissionManager'
+annotation_key = 'Zope.App.Security.AttributePrincipalPermissionManager'
 
 class AttributePrincipalPermissionManager:
     """Mappings between principals and permissions."""
@@ -83,11 +83,11 @@
     def _getPrincipalPermissions(self, create=0):
         """ Get the principal permission map stored in the context, optionally
             creating one if necessary """
-        memo = getAdapter(self._context, IMementoBag)
+        annotations = getAdapter(self._context, IAnnotations)
         try:
-            return memo[memo_key]
+            return annotations[annotation_key]
         except KeyError:
             if create:
-                rp = memo[memo_key] = LocalSecurityMap()
+                rp = annotations[annotation_key] = LocalSecurityMap()
                 return rp
         return None


=== Zope3/lib/python/Zope/App/Security/AttributePrincipalRoleManager.py 1.1.2.5 => 1.1.2.6 ===
 
 from Zope.ComponentArchitecture import getAdapter
-from Zope.App.OFS.Memento.IMementoBag import IMementoBag
+from Zope.App.OFS.Annotation.IAnnotations import IAnnotations
 from Zope.App.Security.IPrincipalRoleManager \
      import IPrincipalRoleManager
 from Zope.App.Security.LocalSecurityMap import LocalSecurityMap
 from Zope.App.Security.Settings import Assign, Remove, Unset
 
-memo_key = 'Zope.App.Security.AttributePrincipalRoleManager'
+annotation_key = 'Zope.App.Security.AttributePrincipalRoleManager'
 
 class AttributePrincipalRoleManager:
     """Mappings between principals and roles."""
@@ -30,48 +30,48 @@
     def __init__(self, context):
         self._context = context
 
-    def assignRoleToPrincipal( self, role_id, principal_id ):
+    def assignRoleToPrincipal(self, role_id, principal_id):
         ''' See the interface IPrincipalRoleManager '''
         pp = self._getPrincipalRoles(create=1)
-        pp.addCell( role_id, principal_id, Assign )
+        pp.addCell(role_id, principal_id, Assign)
         self._context._p_changed = 1
 
-    def removeRoleFromPrincipal( self, role_id, principal_id ):
+    def removeRoleFromPrincipal(self, role_id, principal_id):
         ''' See the interface IPrincipalRoleManager '''
         pp = self._getPrincipalRoles(create=1)
-        pp.addCell( role_id, principal_id, Remove )
+        pp.addCell(role_id, principal_id, Remove)
         self._context._p_changed = 1
 
-    def unsetRoleForPrincipal( self, role_id, principal_id ):
+    def unsetRoleForPrincipal(self, role_id, principal_id):
         ''' See the interface IPrincipalRoleManager '''
         pp = self._getPrincipalRoles()
         # Only unset if there is a security map, otherwise, we're done
         if pp:
-            pp.delCell( role_id, principal_id )
+            pp.delCell(role_id, principal_id)
             self._context._p_changed = 1
 
-    def getPrincipalsForRole( self, role_id ):
+    def getPrincipalsForRole(self, role_id):
         ''' See the interface IPrincipalRoleManager '''
         pp = self._getPrincipalRoles()
         if pp: 
-            return pp.getRow( role_id )
+            return pp.getRow(role_id)
         return []
 
-    def getRolesForPrincipal( self, principal_id ):
+    def getRolesForPrincipal(self, principal_id):
         ''' See the interface IPrincipalRoleManager '''
         pp = self._getPrincipalRoles()
         if pp: 
-            return pp.getCol( principal_id )
+            return pp.getCol(principal_id)
         return []
 
-    def getSetting( self, role_id, principal_id ):
+    def getSetting(self, role_id, principal_id):
         ''' See the interface IPrincipalRoleManager '''
         pp = self._getPrincipalRoles()
         if pp: 
-            return pp.getCell( role_id, principal_id, default=Unset )
+            return pp.getCell(role_id, principal_id, default=Unset)
         return Unset
 
-    def getPrincipalsAndRoles( self ):
+    def getPrincipalsAndRoles(self):
         ''' See the interface IPrincipalRoleManager '''
         pp = self._getPrincipalRoles()
         if pp:
@@ -83,11 +83,11 @@
     def _getPrincipalRoles(self, create=0):
         """ Get the principal role map stored in the context, optionally
             creating one if necessary """
-        memo = getAdapter(self._context, IMementoBag)
+        annotations = getAdapter(self._context, IAnnotations)
         try:
-            return memo[memo_key]
+            return annotations[annotation_key]
         except KeyError:
             if create:
-                rp = memo[memo_key] = LocalSecurityMap()
+                rp = annotations[annotation_key] = LocalSecurityMap()
                 return rp
         return None


=== Zope3/lib/python/Zope/App/Security/AttributeRolePermissionManager.py 1.1.2.10 => 1.1.2.11 ===
 
 from Zope.ComponentArchitecture import getAdapter
-from Zope.App.OFS.Memento.IMementoBag import IMementoBag
+from Zope.App.OFS.Annotation.IAnnotations import IAnnotations
 from Zope.App.Security.IRolePermissionManager import IRolePermissionManager
 from Zope.App.Security.LocalSecurityMap import LocalSecurityMap
 from Zope.App.Security.Settings import Allow, Deny, Unset
 
-memo_key = 'Zope.App.Security.AttributeRolePermissionManager'
+annotation_key = 'Zope.App.Security.AttributeRolePermissionManager'
 
 class  AttributeRolePermissionManager:
     """
@@ -89,12 +89,12 @@
     def _getRolePermissions(self, create=0):
         """ Get the role permission map stored in the context, optionally
             creating one if necessary """
-        memo = getAdapter(self._context, IMementoBag)
+        annotations = getAdapter(self._context, IAnnotations)
         try:
-            return memo[memo_key]
+            return annotations[annotation_key]
         except KeyError:
             if create:
-                rp = memo[memo_key] = LocalSecurityMap()
+                rp = annotations[annotation_key] = LocalSecurityMap()
                 return rp
         return None
 


=== Zope3/lib/python/Zope/App/Security/security.zcml 1.1.2.6 => 1.1.2.7 ===
    xmlns:browser='http://namespaces.zope.org/browser'
 >
-  <serviceType name="RoleService" 
-               interface="Zope.App.Security.IRoleService." />
-  <service name="RoleService" 
-           component="Zope.App.Security.RoleRegistry.roleRegistry" />
-
-
-  <serviceType name="PermissionService" 
-               interface="Zope.App.Security.IPermissionService." />
-  <service name="PermissionService" 
-         component="Zope.App.Security.PermissionRegistry.permissionRegistry" />
-
-  <serviceType name="AuthenticationService" 
-               interface="Zope.App.Security.IAuthenticationService." />
-  <service name="AuthenticationService" 
-           component="Zope.App.Security.PrincipalRegistry.principalRegistry" />
+  <serviceType
+      name="RoleService" 
+      interface="Zope.App.Security.IRoleService." />
+  <service
+      name="RoleService" 
+      component="Zope.App.Security.RoleRegistry.roleRegistry" />
+
+  <serviceType
+      name="PermissionService" 
+      interface="Zope.App.Security.IPermissionService." />
+  <service
+      name="PermissionService" 
+      component="Zope.App.Security.PermissionRegistry.permissionRegistry" />
+
+  <serviceType
+      name="AuthenticationService" 
+      interface="Zope.App.Security.IAuthenticationService." />
+  <service
+      name="AuthenticationService" 
+      component="Zope.App.Security.PrincipalRegistry.principalRegistry" />
 
 <security:defaultPolicy 
   name="Zope.App.Security.ZopeSecurityPolicy.zopeSecurityPolicy" />
@@ -48,7 +53,7 @@
 
 
 <browser:view name="RolePermissionsManagement"
-              for="Zope.App.OFS.Memento.IAttributeMementoStorable."
+              for="Zope.App.OFS.Annotation.IAttributeAnnotatable."
               factory="Zope.App.Security.RolePermissionView." />
 
 <!-- Principal-Permission management view -->
@@ -61,7 +66,7 @@
 
 
 <browser:view name="PrincipalPermissionsManagement"
-              for="Zope.App.OFS.Memento.IAttributeMementoStorable."
+              for="Zope.App.OFS.Annotation.IAttributeAnnotatable."
               factory="Zope.App.Security.PrincipalPermissionView." />
 
 <!-- protect Roles and Permissions -->