[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Security - AttributeRolePermissionManager.py:1.1.2.2

Jim Fulton jim@zope.com
Thu, 3 Jan 2002 14:01:56 -0500


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

Modified Files:
      Tag: Zope-3x-branch
	AttributeRolePermissionManager.py 
Log Message:
Added retract method.

Got rid of redundant doc strings. Methods are documented by
interfaces.


=== Zope3/lib/python/Zope/App/Security/AttributeRolePermissionManager.py 1.1.2.1 => 1.1.2.2 ===
         self._context = context
 
-    def getPermissionsForRole(self, role):
-        """Return the list of permissions for the given role.
+    # Implementation methods for interface
+    # Zope.App.Security.IRolePermissionManager
 
-        role must be an IRole.  If no permissions have been granted to this
-        role, then the empty list is returned.
-        """
+    def getPermissionsForRole(self, role):
+        '''See interface IRolePermissionMap'''
         try:
             rp = self._context.__role_permissions__
         except AttributeError:
@@ -42,11 +41,7 @@
         return rp.get(role, ())
 
     def getRolesForPermission(self, permission):
-        """Return the list of roles for the given permission.
-
-        permission must be an IPermission.  If no roles have been granted
-        this permission, then the empty list is returned.
-        """
+        '''See interface IRolePermissionMap'''
         try:
             rp = self._context.__role_permissions__
         except AttributeError:
@@ -60,17 +55,20 @@
         return r
 
     def getPermissionAcquired(self, permission):
-        """Return a flag indicating whether permission settings are acquired.
-        """
+        '''See interface IRolePermissionMap'''
         # punt for now
         return 1
 
+    def retractPermissionFromRole(self, permission, role):
+        '''See interface IRolePermissionMap'''
+        rp = getattr(self._context, '__role_permissions__', None)
+        if rp:
+            permissions = rp.get(role, ())
+            if permission in permissions:
+                permissions.remove(permission)
+        
     def grantPermissionToRole(self, permission, role):
-        """Bind the permission to the role.
-
-        permission must be an IPermission
-        role must be an IRole
-        """
+        '''See interface IRolePermissionMap'''
         permissionService = getService(self._context,
                                        'PermissionService')
         p = permissionService.getPermission(permission)
@@ -99,7 +97,5 @@
                 self._context._p_changed = 1
 
     def setPermissionAcquired(self, permission, flag):
-        """Set a flag indicating whether permission settings are acquired.
-
-        Permission settings are acquired by default.
-        """
+        '''See interface IRolePermissionMap'''
+        raise TypeError('Unimplemented')