[Zope-Checkins] CVS: Zope/lib/python/AccessControl - ZopeGuards.py:1.16.2.3

Jim Fulton jim at zope.com
Fri Jan 16 16:04:57 EST 2004


Update of /cvs-repository/Zope/lib/python/AccessControl
In directory cvs.zope.org:/tmp/cvs-serv17021/lib/python/AccessControl

Modified Files:
      Tag: Zope-2_7-branch
	ZopeGuards.py 
Log Message:
Changed guarded_getattr to use the new strategy.

Reverted a change that suppressed passing names to validate when doing
item access.


=== Zope/lib/python/AccessControl/ZopeGuards.py 1.16.2.2 => 1.16.2.3 ===
--- Zope/lib/python/AccessControl/ZopeGuards.py:1.16.2.2	Fri Jan 16 13:12:10 2004
+++ Zope/lib/python/AccessControl/ZopeGuards.py	Fri Jan 16 16:04:56 2004
@@ -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`
 
@@ -155,16 +155,20 @@
 # See comment in SimpleObjectPolicies for an explanation of what the
 # dicts below actually mean.
 
-ContainerAssertions[type({})] = {
-    'clear':1, 'copy':1, 'fromkeys':1, 'get':get_dict_get, 'has_key':1,
-    'items':1, 'iteritems':1, 'keys':1,
+dict_handlers = {
+    'get':get_dict_get, 'has_key':1,
     'iterkeys': get_iter,  'itervalues':get_iter,
-    'pop':get_dict_pop, 'popitem':1, 'setdefault':1, 'update':1, 'values':1}
+    'pop':get_dict_pop, }
+def dict_attr_factory(attr, v, handlers = dict_handlers):
+    return handlers.get(attr, 1)
 
-ContainerAssertions[type([])] = {
-    'append':1, 'count':1, 'extend':1, 'index':1, 'insert':1,
-    'pop':get_list_pop, 'remove':1, 'reverse':1, 'sort':1}
+ContainerAssertions[type({})] = dict_attr_factory
 
+list_handlers = {'pop':get_list_pop, }
+def list_attr_factory(attr, v, handlers = list_handlers):
+    return handlers.get(attr, 1)
+
+ContainerAssertions[type([])] = list_attr_factory
 
 # This implementation of a "safe" iterator uses a global guard()
 # function to implement the actual guard.  This check is defined as a




More information about the Zope-Checkins mailing list