Log message for revision 38120: Collector #1182: BBB Forward port fix from 2.7 branch (19 months ago!). This change reverts 'guarded_getitem' to pass the 'index' argument as the name to 'validate'. This change will *not* be propagated to the trunk, because the resolution of #1182 specifies that the reverted behavior (i.e., passing None for item accces) is to become the standard implementation as of 2.9.
Changed: U Zope/branches/Zope-2_8-branch/doc/CHANGES.txt U Zope/branches/Zope-2_8-branch/lib/python/AccessControl/ZopeGuards.py U Zope/branches/Zope-2_8-branch/lib/python/AccessControl/tests/testZopeGuards.py -=- Modified: Zope/branches/Zope-2_8-branch/doc/CHANGES.txt =================================================================== --- Zope/branches/Zope-2_8-branch/doc/CHANGES.txt 2005-08-27 00:47:39 UTC (rev 38119) +++ Zope/branches/Zope-2_8-branch/doc/CHANGES.txt 2005-08-27 16:17:42 UTC (rev 38120) @@ -26,6 +26,13 @@ Bugs Fixed + - Collector #1182: BBB Forward port fix from 2.7 branch (19 months + ago!), reverting 'guarded_getitem' to pass the 'index' argument as + the name to 'validate'. This change is *not* propagated to the + trunk, because the resolution of #1182 specifies that the reverted + behavior (i.e., passing None for item accces) is to become the + standard implementation as of 2.9. + - Collector #1877: skel/Products/README.txt inappropriately copied from CMF. Modified: Zope/branches/Zope-2_8-branch/lib/python/AccessControl/ZopeGuards.py =================================================================== --- Zope/branches/Zope-2_8-branch/lib/python/AccessControl/ZopeGuards.py 2005-08-27 00:47:39 UTC (rev 38119) +++ Zope/branches/Zope-2_8-branch/lib/python/AccessControl/ZopeGuards.py 2005-08-27 16:17:42 UTC (rev 38120) @@ -68,7 +68,7 @@ if Containers(type(object)) and Containers(type(v)): # Simple type. Short circuit. return v - if getSecurityManager().validate(object, object, None, v): + if getSecurityManager().validate(object, object, index, v): return v raise Unauthorized, 'unauthorized access to element %s' % `i` Modified: Zope/branches/Zope-2_8-branch/lib/python/AccessControl/tests/testZopeGuards.py =================================================================== --- Zope/branches/Zope-2_8-branch/lib/python/AccessControl/tests/testZopeGuards.py 2005-08-27 00:47:39 UTC (rev 38119) +++ Zope/branches/Zope-2_8-branch/lib/python/AccessControl/tests/testZopeGuards.py 2005-08-27 16:17:42 UTC (rev 38120) @@ -119,7 +119,31 @@ finally: ContainerAssertions[_dict] = old +class TestGuardedGetitem(GuardTestCase): + def setUp(self): + self.sm = SecurityManager() + self.old = self.setSecurityManager(self.sm) + + def tearDown(self): + self.setSecurityManager(self.old) + + def test_guarded_getitem_passes_index_to_validate(self): + # BBB: collector #1182 specifies that guarded_getitem should be + # passing the 'index' to validate, rather than 'None', + # until Zope 2.9. + from UserDict import UserDict + from AccessControl.ZopeGuards import guarded_getitem + + foo = [] + protected = UserDict(foo=foo) + + value = guarded_getitem(protected, 'foo') + self.failUnless(value is foo) + self.assertEqual(len(self.sm.calls), 1) + self.assertEqual(self.sm.calls[0], + ('validate', (protected, protected, 'foo', foo))) + class TestDictGuards(GuardTestCase): def test_get_simple(self): @@ -650,6 +674,7 @@ def test_suite(): suite = unittest.TestSuite() for cls in (TestGuardedGetattr, + TestGuardedGetitem, TestDictGuards, TestBuiltinFunctionGuards, TestListGuards, _______________________________________________ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins