[Zope3-checkins] CVS: Zope3/src/zope/proxy - __init__.py:1.5

Stephan Richter srichter@cbu.edu
Sat, 19 Apr 2003 06:34:39 -0400


Update of /cvs-repository/Zope3/src/zope/proxy
In directory cvs.zope.org:/tmp/cvs-serv10462/src/zope/proxy

Modified Files:
	__init__.py 
Log Message:
Fixed the proxy_compatible_isinstance() function. 

It would barf, if the object itself was a class, which was actually the
case when a form error is displayed on the Web.


=== Zope3/src/zope/proxy/__init__.py 1.4 => 1.5 ===
--- Zope3/src/zope/proxy/__init__.py:1.4	Thu Apr 17 11:19:00 2003
+++ Zope3/src/zope/proxy/__init__.py	Sat Apr 19 06:34:38 2003
@@ -15,7 +15,7 @@
 
 $Id$
 """
-
+from types import ClassType
 from zope.proxy.introspection import removeAllProxies
 
 
@@ -27,6 +27,10 @@
     """
     if isinstance(obj, cls):
         return True
+    # Check whether the object is a class itself, if so abort, otherwise the
+    # next check will fail.
+    if type(removeAllProxies(obj)) == ClassType:
+        return False
     oclass = removeAllProxies(obj.__class__)
     if type(obj) is oclass:
         # Nothing more will help