[Zope3-checkins] CVS: Zope3/lib/python/Zope/Security - Checker.py:1.7.6.1

Jim Fulton jim@zope.com
Thu, 14 Nov 2002 13:27:12 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/Security
In directory cvs.zope.org:/tmp/cvs-serv15337

Modified Files:
      Tag: Zope3-Bangalore-TTW-Branch
	Checker.py 
Log Message:
Fixed bug: Proxy creation wasn't done correctly for context-wrapped objects

=== Zope3/lib/python/Zope/Security/Checker.py 1.7 => 1.7.6.1 ===
--- Zope3/lib/python/Zope/Security/Checker.py:1.7	Tue Oct  1 08:47:50 2002
+++ Zope3/lib/python/Zope/Security/Checker.py	Thu Nov 14 13:27:12 2002
@@ -243,8 +243,24 @@
     The appropriate checker is returned or None is returned. If the
     return value is None, then object should not be wrapped in a proxy.
     """
-    checker = _getChecker(type(object), _defaultChecker)
+
+    # We need to be careful here. We might have a proxy, in which case
+    # we can't use the type.  OTOH, we might not be able to use the
+    # __class__ either, since not everything has one.
+
+    # XXX we really need formal proxy introspection
+
+    if type(object) is Proxy:
+        # Is this already a security proxy?
+        return None
+    
+    checker = _getChecker(getattr(object, '__class__', type(object)),
+                          _defaultChecker)
+    
     if checker is NoProxy:
+        return None
+
+    if checker is _defaultChecker and isinstance(object, Exception):
         return None
 
     while not isinstance(checker, Checker):