[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/Security/Registries - PermissionRegistry.py:1.2
Viktorija Zaksiene
ryzaja@codeworks.lt
Mon, 25 Nov 2002 10:23:21 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/Security/Registries
In directory cvs.zope.org:/tmp/cvs-serv7564/Security/Registries
Modified Files:
PermissionRegistry.py
Log Message:
Added check for undefined permissions on configuration time.
=== Zope3/lib/python/Zope/App/Security/Registries/PermissionRegistry.py 1.1 => 1.2 ===
--- Zope3/lib/python/Zope/App/Security/Registries/PermissionRegistry.py:1.1 Thu Jun 20 11:55:02 2002
+++ Zope3/lib/python/Zope/App/Security/Registries/PermissionRegistry.py Mon Nov 25 10:23:21 2002
@@ -21,6 +21,9 @@
from Zope.App.Security.Registries.Registry import Registry
from Zope.App.Security.IPermission import IPermission
from Zope.App.Security.IPermissionService import IPermissionService
+from Zope.Security.Checker import CheckerPublic
+from Zope.App.Security.Exceptions import UndefinedPermissionError
+
class Permission(RegisteredObject):
@@ -52,6 +55,16 @@
false
"""
return self.is_registered(permission_id)
+
+ def ensurePermissionDefined(self, permission_id):
+ """Check to make sure permission is defined.
+
+ If it isn't, an error is raised
+ """
+ if permission_id == CheckerPublic:
+ return
+ if not self.definedPermission(permission_id):
+ raise UndefinedPermissionError(permission_id)
def getPermission(self, permission_id):
"""Return permission object registered as permission_id.