[Zope-Checkins] CVS: Packages/RestrictedPython - Guards.py:

Tres Seaver tseaver at palladion.com
Sat May 28 20:42:16 EDT 2005

Update of /cvs-repository/Packages/RestrictedPython
In directory cvs.zope.org:/tmp/cvs-serv32028/lib/python/RestrictedPython

Modified Files:
      Tag: tseaver-hasattr_geddon-branch
Log Message:

  - Removed all uses of the 'hasattr' builtin from the core, where
    the object being tested derives (or might) from Persistent.
    XXX:  currently, this branch imports a 'safe_hasattr' from ZODB.utils,
    which adds a dependency on ZODB for some packages;  we probably
    need a better location, and perhas a C implementation?

=== Packages/RestrictedPython/Guards.py => ===
--- Packages/RestrictedPython/Guards.py:	Thu Jan  8 18:33:56 2004
+++ Packages/RestrictedPython/Guards.py	Sat May 28 20:41:35 2005
@@ -13,6 +13,7 @@
 import exceptions
+from ZODB.utils import safe_hasattr
 # This tiny set of safe builtins is extended by users of the module.
 # AccessControl.ZopeGuards contains a large set of wrappers for builtins.
@@ -120,7 +121,7 @@
     def guard(ob):
         # Don't bother wrapping simple types, or objects that claim to
         # handle their own write security.
-        if safetype(type(ob)) or hasattr(ob, '_guarded_writes'):
+        if safetype(type(ob)) or safe_hasattr(ob, '_guarded_writes'):
             return ob
         # Hand the object to the Wrapper instance, then return the instance.
         return Wrapper(ob)

More information about the Zope-Checkins mailing list