[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Security - PrincipalPermissionManager.py:1.1.2.4
Anthony Baxter
anthony@interlink.com.au
Fri, 8 Feb 2002 15:05:45 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/Security
In directory cvs.zope.org:/tmp/cvs-serv29142
Modified Files:
Tag: Zope-3x-branch
PrincipalPermissionManager.py
Log Message:
Checking in new PrincipalPermissionManager. The Security unit tests will
be broken for a short while until we finish the whiteboarding and fix the
code. (wasn't planning to break it immediately, but what the heck, Andreas
already broke it with the RolePermissionManager changes :)
=== Zope3/lib/python/Zope/App/Security/PrincipalPermissionManager.py 1.1.2.3 => 1.1.2.4 ===
from Zope.App.Security.IPrincipalPermissionManager \
import IPrincipalPermissionManager
-from Zope.App.Security.SecurityMap import SecurityMap
+from Zope.App.Security.LocalSecurityMap import LocalSecurityMap
+from Zope.App.Security.Settings import Allow, Deny, Unset
-class PrincipalPermissionManager(SecurityMap):
+class PrincipalPermissionManager(LocalSecurityMap):
"""Mappings between principals and permissions."""
__implements__ = IPrincipalPermissionManager
- """Bind the permission to the principal.
-
- permission must be an IPermission
- principal must be an IPrincipal
- """
def grantPermissionToPrincipal( self, permission, principal ):
- self.addCell( permission, principal )
+ ''' See the interface IPrincipalPermissionManager '''
+ self.addCell( permission, principal, Allow )
- """Return the list of principals for the given permission.
+ def denyPermissionToPrincipal( self, permission, principal ):
+ ''' See the interface IPrincipalPermissionManager '''
+ self.addCell( permission, principal, Deny )
+
+ def unsetPermissionForPrincipal( self, permission, principal ):
+ ''' See the interface IPrincipalPermissionManager '''
+ self.delCell( permission, principal )
- permission must be an IPermission. If no principals have been granted
- this permission, then the empty list is returned.
- """
def getPrincipalsForPermission( self, permission ):
- return self.getColumnsForRow( permission )
-
- """Return the list of permissions for the given principal.
+ ''' See the interface IPrincipalPermissionManager '''
+ return self.getRow( permission )
- principal must be an IPrincipal. If no permissions have been granted
- to this principal, then the empty list is returned.
- """
def getPermissionsForPrincipal( self, principal ):
- return self.getRowsForColumn( principal )
-
+ ''' See the interface IPrincipalPermissionManager '''
+ return self.getCol( principal )
# Permissions are our rows, and principals are our columns
principalPermissionManager = PrincipalPermissionManager()