[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Security - PermissionRegistry.py:1.1.2.13
Jim Fulton
jim@zope.com
Wed, 26 Dec 2001 15:32:47 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/Security
In directory cvs.zope.org:/tmp/cvs-serv31478
Modified Files:
Tag: Zope-3x-branch
PermissionRegistry.py
Log Message:
Got rid of permission_id obfuscation for now.
Added public permission definition to initialization so
that it's not lost by a clear.
Exported registry with a less generic name.
=== Zope3/lib/python/Zope/App/Security/PermissionRegistry.py 1.1.2.12 => 1.1.2.13 ===
self._prefix = prefix
- def _make_global_id(self, suffix):
- return self._prefix + '.' + suffix
-
def definePermission(self, permission, title, description=''):
"""Define a new permission object, register, and return it.
name is the permission name, must be globally unique
- title (optional) is the permission title, human readable. If omitted
- then the name is used as the title
+ title is the permission title, human readable.
description (optional) is human readable
"""
- if description is None:
- description = ''
- return self.register(self._make_global_id(permission),
- title, description)
+ return self.register(permission, title, description)
- def definedPermission(self, name):
+ def definedPermission(self, permission_id):
"""Return true if named permission is registered, otherwise return
false
"""
- return self.is_registered(self._make_global_id(name))
+ return self.is_registered(permission_id)
- def getPermission(self, name):
- """Return permission object registered as name.
+ def getPermission(self, permission_id):
+ """Return permission object registered as permission_id.
If no named permission is registered KeyError is raised.
"""
- return self.getRegisteredObject(self._make_global_id(name))
-
+ return self.getRegisteredObject(permission_id)
-registry = PermissionRegistry()
+ def _clear(self):
+ Registry._clear(self)
+ self.definePermission(
+ 'Zope.Public', 'Public',
+ """Special permission used for resources that are always public
+
+ The public permission is effectively an optimization, sine
+ it allows security computation to be bypassed.
+ """
+ )
-PublicPermission = registry.definePermission(SUFFIX, SUFFIX, DESCRIP)
+permissionRegistry = PermissionRegistry()