[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Security/Grants - AnnotationRolePermissionManager.py:1.3 PermissionRoles.py:1.2
Florent Guillaume
fg@nuxeo.com
Mon, 24 Jun 2002 12:01:15 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/Security/Grants
In directory cvs.zope.org:/tmp/cvs-serv11631
Modified Files:
AnnotationRolePermissionManager.py PermissionRoles.py
Log Message:
Update Role Permission UI to allow Unset/Allow/Deny.
Fix tests, including dummy RolePermissionManager.
Correct interface assertions.
=== Zope3/lib/python/Zope/App/Security/Grants/AnnotationRolePermissionManager.py 1.2 => 1.3 ===
from Zope.App.OFS.Annotation.IAnnotations import IAnnotations
from Zope.App.Security.IRolePermissionManager import IRolePermissionManager
+from Zope.App.Security.IRolePermissionMap import IRolePermissionMap
from Zope.App.Security.Grants.PersistentLocalSecurityMap import \
PersistentLocalSecurityMap
from Zope.App.Security.Settings import Allow, Deny, Unset
@@ -30,7 +31,7 @@
provide adapter that manages role permission data in an object attribute
"""
- __implements__ = IRolePermissionManager
+ __implements__ = IRolePermissionManager, IRolePermissionMap
def __init__(self, context):
self._context = context
=== Zope3/lib/python/Zope/App/Security/Grants/PermissionRoles.py 1.1 => 1.2 ===
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
-#
+#
##############################################################################
"""
@@ -19,7 +19,7 @@
from Zope.ComponentArchitecture import getAdapter
from Zope.App.Security.IRolePermissionManager import IRolePermissionManager
from Zope.App.Security.IPermission import IPermission
-from Zope.App.Security.Settings import Allow
+from Zope.App.Security.Settings import Unset, Allow, Deny
class PermissionRoles:
@@ -39,13 +39,18 @@
def getDescription(self):
return self._permission.getDescription()
- def roles(self):
+ def roleSettings(self):
+ """
+ Returns the list of setting names of each role for this permission.
+ """
prm = getAdapter(self._context, IRolePermissionManager)
proles = prm.getRolesForPermission(self._permission.getId())
- proles = [role for role,setting in proles if setting==Allow]
- return [((role.getId() in proles) and '1' or None)
- for role in self._roles]
-
+ settings = {}
+ for role, setting in proles:
+ settings[role] = setting.getName()
+ nosetting = Unset.getName()
+ return [settings.get(role.getId(), nosetting) for role in self._roles]
+
def rolesInfo(self):
prm = getAdapter(self._context, IRolePermissionManager)
proles = prm.getRolesForPermission(self._permission.getId())