[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/ContentDirective - ContentDirective.py:1.12
Viktorija Zaksiene
ryzaja@codeworks.lt
Mon, 25 Nov 2002 10:23:51 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/ContentDirective
In directory cvs.zope.org:/tmp/cvs-serv7564/ContentDirective
Modified Files:
ContentDirective.py
Log Message:
Added check for undefined permissions on configuration time.
=== Zope3/lib/python/Zope/App/ContentDirective/ContentDirective.py 1.11 => 1.12 ===
--- Zope3/lib/python/Zope/App/ContentDirective/ContentDirective.py:1.11 Tue Nov 19 18:25:12 2002
+++ Zope3/lib/python/Zope/App/ContentDirective/ContentDirective.py Mon Nov 25 10:23:20 2002
@@ -25,6 +25,7 @@
from Zope.App.ComponentArchitecture.ClassFactory import ClassFactory
from Zope.App.Security.protectClass \
import protectLikeUnto, protectName, checkPermission, protectSetAttribute
+from Zope.App.Security.Registries.PermissionRegistry import permissionRegistry
from Zope.Security.Proxy import ProxyFactory
from Zope.Security.Checker import NamesChecker
from Zope.Schema.IField import IField
@@ -39,6 +40,11 @@
method=getattr(getService(None, serviceName), methodName)
method(*args, **kwargs)
+def assertPermission(permission=None, *args, **kw):
+ """Check if permission is defined"""
+ if permission is not None:
+ permissionRegistry.ensurePermissionDefined(permission)
+
class ContentDirective:
__class_implements__ = INonEmptyDirective
@@ -188,7 +194,8 @@
- set component permission
"""
-
+
+ assertPermission(permission)
factory = ClassFactory(_class)
if permission and (permission != 'Zope.Public'):
# XXX should getInterfaces be public, as below?