[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Security - RolePermissionView.py:1.1.2.4
Fred L. Drake, Jr.
fdrake@acm.org
Thu, 31 Jan 2002 17:28:41 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/Security
In directory cvs.zope.org:/tmp/cvs-serv11220
Modified Files:
Tag: Zope-3x-branch
RolePermissionView.py
Log Message:
Preliminary Permissions management page (local only).
=== Zope3/lib/python/Zope/App/Security/RolePermissionView.py 1.1.2.3 => 1.1.2.4 ===
index = PageTemplateFile('pt/manage_access.pt')
+ manage_permissionForm = PageTemplateFile('pt/manage_permissionForm.pt')
def roles(self):
roles = getattr(self, '_roles', None)
@@ -50,6 +51,13 @@
return [PermissionRoles(permission, context, roles)
for permission in self.permissions()]
+ def permissionForID(self, pid):
+ context = self.getContext()
+ roles = self.roles()
+ perm = getService(self.getContext(), 'PermissionService'
+ ).getPermission(pid)
+ return PermissionRoles(perm, context, roles)
+
def action(self, REQUEST, testing=None):
roles = [r.getId() for r in self.roles()]
permissions = [p.getId() for p in self.permissions()]
@@ -77,7 +85,8 @@
def __init__(self, permission, context, roles):
self._permission = permission
self._context = context
- self._roles = [role.getId() for role in roles]
+ self._roles = roles
+ #self._roles = [role.getId() for role in roles]
def getId(self):
return self._permission.getId()
@@ -91,7 +100,13 @@
def roles(self):
prm = getAdapter(self._context, IRolePermissionManager)
proles = prm.getRolesForPermission(self._permission.getId())
- return [((role in proles) and '1' or None) for role in self._roles]
-
-
+ return [((role.getId() in proles) and '1' or None)
+ for role in self._roles]
+ def rolesinfo(self):
+ prm = getAdapter(self._context, IRolePermissionManager)
+ proles = prm.getRolesForPermission(self._permission.getId())
+ return [{'id': role.getId(),
+ 'title': role.getTitle(),
+ 'checked': ((role.getId() in proles) and '1' or None)}
+ for role in self._roles]