[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/ Fixed a couple of permission fields in schemas -- they should use permission

Marius Gedminas marius at pov.lt
Sat Jun 12 12:42:10 EDT 2004


Log message for revision 25407:
Fixed a couple of permission fields in schemas -- they should use permission
ids, not Permission objects.  Note that this is not entirely correct --
UtilityVocabulary returns 'zope.Public', but we want CheckerPublic.  There
is now an issue in the Zope 3 developement collector about this.




-=-
Modified: Zope3/trunk/src/zope/app/adapter/adapter.py
===================================================================
--- Zope3/trunk/src/zope/app/adapter/adapter.py	2004-06-12 16:36:17 UTC (rev 25406)
+++ Zope3/trunk/src/zope/app/adapter/adapter.py	2004-06-12 16:42:09 UTC (rev 25407)
@@ -306,7 +306,7 @@
 
     permission = zope.schema.Choice(
         title=_(u"The permission required for use"),
-        vocabulary="Permissions",
+        vocabulary="Permission Ids",
         readonly=False,
         required=False,
         )

Modified: Zope3/trunk/src/zope/app/presentation/pagefolder.py
===================================================================
--- Zope3/trunk/src/zope/app/presentation/pagefolder.py	2004-06-12 16:36:17 UTC (rev 25406)
+++ Zope3/trunk/src/zope/app/presentation/pagefolder.py	2004-06-12 16:42:09 UTC (rev 25407)
@@ -73,7 +73,7 @@
     permission = Choice(
         title=_(u"Permission"),
         description=_(u"The permission required to use the view"),
-        vocabulary="Permissions",
+        vocabulary="Permission Ids",
         required = True,
         )
 

Modified: Zope3/trunk/src/zope/app/presentation/presentation.py
===================================================================
--- Zope3/trunk/src/zope/app/presentation/presentation.py	2004-06-12 16:36:17 UTC (rev 25406)
+++ Zope3/trunk/src/zope/app/presentation/presentation.py	2004-06-12 16:42:09 UTC (rev 25407)
@@ -492,6 +492,14 @@
     def __init__(self, cls, template, permission):
         self.cls, self.template, self.permission = cls, template, permission
 
+        # XXX Trap code that uses 'Permissions' vocabulary instead of
+        #     'Permission Ids'.  This check should go away once the mess
+        #     with permissions is straigthened up.
+        from zope.app.security.permission import Permission
+        if isinstance(permission, Permission):
+            raise TypeError('permission should be a string or CheckerPublic,'
+                            ' not %r' % permission)
+
     def __call__(self, object, request):
         checker = NamesChecker(__call__ = self.permission)
         template = BoundTemplate(self.template, self.cls(object, request))




More information about the Zope3-Checkins mailing list