[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/container/browser/ instead of asking whether the user has a particular permission, ask whether

Fred L. Drake, Jr. fdrake at gmail.com
Fri Jul 8 14:05:01 EDT 2005


Log message for revision 31037:
  instead of asking whether the user has a particular permission, ask whether
  the user can change the relevant attribute
  

Changed:
  U   Zope3/trunk/src/zope/app/container/browser/contents.py
  U   Zope3/trunk/src/zope/app/container/browser/tests/test_contents.py

-=-
Modified: Zope3/trunk/src/zope/app/container/browser/contents.py
===================================================================
--- Zope3/trunk/src/zope/app/container/browser/contents.py	2005-07-08 15:54:51 UTC (rev 31036)
+++ Zope3/trunk/src/zope/app/container/browser/contents.py	2005-07-08 18:05:00 UTC (rev 31037)
@@ -22,7 +22,7 @@
 from zope.app.exception.interfaces import UserError
 from zope.app.traversing.interfaces import TraversalError
 from zope.security.interfaces import Unauthorized
-from zope.security import checkPermission
+from zope.security import canWrite
 
 from zope.app import zapi
 from zope.app.size.interfaces import ISized
@@ -166,8 +166,7 @@
 
         dc = IZopeDublinCore(obj, None)
         if dc is not None:
-            info['retitleable'] = checkPermission(
-                'zope.app.dublincore.change', dc) and id != retitle_id
+            info['retitleable'] = canWrite(dc, 'title')
             info['plaintitle'] = not info['retitleable']
 
             title = self.safe_getattr(dc, 'title', None)

Modified: Zope3/trunk/src/zope/app/container/browser/tests/test_contents.py
===================================================================
--- Zope3/trunk/src/zope/app/container/browser/tests/test_contents.py	2005-07-08 15:54:51 UTC (rev 31036)
+++ Zope3/trunk/src/zope/app/container/browser/tests/test_contents.py	2005-07-08 18:05:00 UTC (rev 31037)
@@ -18,6 +18,7 @@
 from unittest import TestCase, TestSuite, main, makeSuite
 
 from zope.interface import Interface, implements
+from zope.security import checker
 
 from zope.app.annotation.interfaces import IAnnotations
 from zope.app.component.testing import PlacefulSetup
@@ -105,6 +106,13 @@
         class FauxDCAdapter(object):
             implements(IZopeDublinCore)
 
+            __Security_checker__ = checker.Checker(
+                {"created": "zope.Public",
+                 "modified": "zope.Public",
+                 "title": "zope.Public",
+                 },
+                {"title": "zope.app.dublincore.change"})
+
             def __init__(self, context):
                 pass
             title = 'faux title'



More information about the Zope3-Checkins mailing list