[Zope-Checkins] CVS: Zope2 - Guards.py:1.1.2.5

shane@digicool.com shane@digicool.com
Thu, 26 Apr 2001 18:25:43 -0400 (EDT)


Update of /cvs-repository/Zope2/lib/python/RestrictedPython
In directory korak:/tmp/cvs-serv10837/lib/python/RestrictedPython

Modified Files:
      Tag: RestrictedPythonBranch
	Guards.py 
Log Message:
Modified the way DTML namespaces implement security: now there is an
attribute of TemplateDicts called read_guard which implements the
"read guard" interface as defined by RestrictedPython.



--- Updated File Guards.py in package Zope2 --
--- Guards.py	2001/04/26 19:13:39	1.1.2.4
+++ Guards.py	2001/04/26 22:25:10	1.1.2.5
@@ -105,13 +105,13 @@
 
 def _full_read_guard(g_attr, g_item):
     # Nested scope abuse!
-    # The three arguments are used by class Wrapper
+    # The two arguments are used by class Wrapper
     # safetype variable is used by guard()
     safetype = {type(()): 1, type([]): 1, type({}): 1, type(''): 1}.has_key
     def guard(ob):
         # Don't bother wrapping simple types, or objects that claim to
         # handle their own read security.
-        if safetype(type(ob)) or hasattr(ob, '_guarded_reads'):
+        if safetype(type(ob)) or getattr(ob, '_guarded_reads', 0):
             return ob
         # ob is shared by class Wrapper, so the class instance wraps it.
         class Wrapper: