[Zope3-checkins] CVS: Zope3/src/zope/app/securitypolicy -
configure.zcml:1.6 metadirectives.py:1.2
permissionroles.py:1.4 rolepermission.py:1.4 zopepolicy.py:1.4
Stephan Richter
srichter at cosmos.phy.tufts.edu
Mon Mar 8 07:06:35 EST 2004
Update of /cvs-repository/Zope3/src/zope/app/securitypolicy
In directory cvs.zope.org:/tmp/cvs-serv13053/src/zope/app/securitypolicy
Modified Files:
configure.zcml metadirectives.py permissionroles.py
rolepermission.py zopepolicy.py
Log Message:
Adjusted code to use the new APIs for permissions and principals. Also, use
the utility service instead of the permission registry to look up permissions.
=== Zope3/src/zope/app/securitypolicy/configure.zcml 1.5 => 1.6 ===
--- Zope3/src/zope/app/securitypolicy/configure.zcml:1.5 Fri Mar 5 13:38:17 2004
+++ Zope3/src/zope/app/securitypolicy/configure.zcml Mon Mar 8 07:06:03 2004
@@ -9,9 +9,6 @@
<modulealias module=".securitymap"
alias="zope.app.security.grants.securitymap"/>
- <modulealias module=".role"
- alias="zope.app.services.role" />
-
<modulealias module="zope.app.securitypolicy"
alias="zope.products.securitypolicy" />
@@ -20,14 +17,12 @@
<content class=".permissionroles.PermissionRoles">
<require permission="zope.Security"
- attributes="roles rolesInfo"
- interface="zope.app.interfaces.security.IRegisteredObject" />
+ attributes="roles rolesInfo id title description" />
</content>
<content class=".rolepermission.RolePermissions">
<require permission="zope.Security"
- attributes="permissions permissionsInfo"
- interface="zope.app.interfaces.security.IRegisteredObject" />
+ attributes="permissions permissionsInfo id title description" />
</content>
<adapter factory=".rolepermission.AnnotationRolePermissionManager"
=== Zope3/src/zope/app/securitypolicy/metadirectives.py 1.1 => 1.2 ===
--- Zope3/src/zope/app/securitypolicy/metadirectives.py:1.1 Fri Feb 27 07:46:31 2004
+++ Zope3/src/zope/app/securitypolicy/metadirectives.py Mon Mar 8 07:06:03 2004
@@ -17,7 +17,7 @@
"""
from zope.interface import Interface
from zope.schema import Id
-from zope.app.security.registries.metadirectives import IBaseDefineDirective
+from zope.app.security.metadirectives import IBaseDefineDirective
class IGrantDirective(Interface):
"""Grant Permissions to roles and principals and roles to principals."""
=== Zope3/src/zope/app/securitypolicy/permissionroles.py 1.3 => 1.4 ===
--- Zope3/src/zope/app/securitypolicy/permissionroles.py:1.3 Sat Mar 6 11:50:29 2004
+++ Zope3/src/zope/app/securitypolicy/permissionroles.py Mon Mar 8 07:06:03 2004
@@ -14,14 +14,13 @@
"""
$Id$
"""
-
from zope.interface import implements
-from zope.app.interfaces.security import IPermission
+from zope.app.security.interfaces import IPermission
from zope.app.security.settings import Unset
from zope.app.securitypolicy.interfaces import IRolePermissionManager
-class PermissionRoles:
+class PermissionRoles(object):
implements(IPermission)
@@ -30,21 +29,27 @@
self._context = context
self._roles = roles
- def getId(self):
- return self._permission.getId()
+ def _getId(self):
+ return self._permission.id
+
+ id = property(_getId)
+
+ def _getTitle(self):
+ return self._permission.title
+
+ title = property(_getTitle)
- def getTitle(self):
- return self._permission.getTitle()
+ def _getDescription(self):
+ return self._permission.description
- def getDescription(self):
- return self._permission.getDescription()
+ description = property(_getDescription)
def roleSettings(self):
"""
Returns the list of setting names of each role for this permission.
"""
prm = IRolePermissionManager(self._context)
- proles = prm.getRolesForPermission(self._permission.getId())
+ proles = prm.getRolesForPermission(self._permission.id)
settings = {}
for role, setting in proles:
settings[role] = setting.getName()
=== Zope3/src/zope/app/securitypolicy/rolepermission.py 1.3 => 1.4 ===
--- Zope3/src/zope/app/securitypolicy/rolepermission.py:1.3 Sat Mar 6 11:50:29 2004
+++ Zope3/src/zope/app/securitypolicy/rolepermission.py Mon Mar 8 07:06:03 2004
@@ -33,9 +33,8 @@
# change without breaking existing databases
annotation_key = 'zope.app.security.AnnotationRolePermissionManager'
-class AnnotationRolePermissionManager:
- """
- provide adapter that manages role permission data in an object attribute
+class AnnotationRolePermissionManager(object):
+ """Provide adapter that manages role permission data in an object attribute
"""
implements(IRolePermissionManager, IRolePermissionMap)
@@ -118,7 +117,7 @@
return rp
return None
-class RolePermissions:
+class RolePermissions(object):
implements(IRole)
@@ -127,15 +126,22 @@
self._context = context
self._permissions = permissions
- def getId(self):
+
+ def _getId(self):
return self._role.id
- def getTitle(self):
+ id = property(_getId)
+
+ def _getTitle(self):
return self._role.title
- def getDescription(self):
+ title = property(_getTitle)
+
+ def _getDescription(self):
return self._role.description
+ description = property(_getDescription)
+
def permissionsInfo(self):
prm = IRolePermissionManager(self._context)
rperms = prm.getPermissionsForRole(self._role.id)
@@ -143,9 +149,9 @@
for permission, setting in rperms:
settings[permission] = setting.getName()
nosetting = Unset.getName()
- return [{'id': permission.getId(),
- 'title': permission.getTitle(),
- 'setting': settings.get(permission.getId(), nosetting)}
+ return [{'id': permission.id,
+ 'title': permission.title,
+ 'setting': settings.get(permission.id, nosetting)}
for permission in self._permissions]
=== Zope3/src/zope/app/securitypolicy/zopepolicy.py 1.3 => 1.4 ===
--- Zope3/src/zope/app/securitypolicy/zopepolicy.py:1.3 Sat Mar 6 12:48:53 2004
+++ Zope3/src/zope/app/securitypolicy/zopepolicy.py Mon Mar 8 07:06:03 2004
@@ -73,7 +73,7 @@
return True
roledict = {'zope.Anonymous': Allow}
- principals = {user.getId() : roledict}
+ principals = {user.id : roledict}
role_permissions = {}
remove = {}
@@ -223,7 +223,7 @@
permissions = {}
roles = {'zope.Anonymous': Allow}
- principalid = principal.getId()
+ principalid = principal.id
# Make two passes.
More information about the Zope3-Checkins
mailing list