[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/Security - PermissionField.py:1.2

Steve Alexander steve@cat-box.net
Sun, 22 Dec 2002 16:03:44 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/App/Security
In directory cvs.zope.org:/tmp/cvs-serv5241/lib/python/Zope/App/Security

Modified Files:
	PermissionField.py 
Log Message:
restored to simplicity after Jim pointed out that I was misusing it as
  PermissionField('some docstring')

rather than

  PermissionField(title=u'title here')


=== Zope3/lib/python/Zope/App/Security/PermissionField.py 1.1 => 1.2 ===
--- Zope3/lib/python/Zope/App/Security/PermissionField.py:1.1	Sat Dec 21 14:56:36 2002
+++ Zope3/lib/python/Zope/App/Security/PermissionField.py	Sun Dec 22 16:03:44 2002
@@ -19,7 +19,7 @@
 from Zope.Schema.IField import IValueSet
 from Zope.Schema import ValueSet
 from Zope.Schema.Exceptions import ValidationError
-from Zope.ComponentArchitecture import queryService
+from Zope.ComponentArchitecture import getService
 
 class IPermissionField(IValueSet):
     u"""Fields with Permissions as values
@@ -31,15 +31,7 @@
 
     def _validate(self, value):
         super(PermissionField, self)._validate(value)
-        # XXX I'd like to use getService here, but _validate is called
-        #     before the zcml actions are executed, so this gets
-        #     called before even the Permissions service is set up.
-        service = queryService(self.context, 'Permissions', None)
-        if service is None:
-            # XXX Permissions service not found, so we can't validate.
-            #     Perhaps log some message here.
-            pass
-        else:
-            if service.getPermission(value.getId()) is None:
-                raise ValidationError("Unknown permission", value)
+        service = getService(self.context, 'Permissions')
+        if service.getPermission(value.getId()) is None:
+            raise ValidationError("Unknown permission", value)