[Zope3-checkins] CVS: Zope3/src/zope/proxy - __init__.py:1.9
Sidnei da Silva
sidnei at x3ng.com.br
Wed Jan 14 08:40:19 EST 2004
Update of /cvs-repository/Zope3/src/zope/proxy
In directory cvs.zope.org:/tmp/cvs-serv7325/zope/proxy
Modified Files:
__init__.py
Log Message:
Remove proxy_compatible_isinstance, which according to the docstring (and to Jim) should not be needed anymore. Also, only pagetemplate.engine was using it.
=== Zope3/src/zope/proxy/__init__.py 1.8 => 1.9 ===
--- Zope3/src/zope/proxy/__init__.py:1.8 Tue Nov 4 22:08:12 2003
+++ Zope3/src/zope/proxy/__init__.py Wed Jan 14 08:40:18 2004
@@ -24,41 +24,6 @@
moduleProvides(IProxyIntrospection)
__all__ = tuple(IProxyIntrospection)
-
-
-def proxy_compatible_isinstance(obj, cls):
- """Like built-in isinstance() in Python 2.3.
-
- This honors __class__ if the standard isinstance() fails. This is how it
- works in Python 2.3 so that even proxied objects will succeed the test.
- """
- 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
- return False
- # Note that cls may be a tuple, but issubclass can't deal with that so we
- # need to expand recursively.
- classes = {}
- flatten = [cls]
- while flatten:
- thisclass = flatten.pop(0)
- if thisclass in classes:
- continue
- if isinstance(thisclass, tuple):
- flatten.extend(thisclass)
- else:
- classes[thisclass] = True
- for bclass in classes.keys():
- if issubclass(oclass, bclass):
- return True
- return False
-
def ProxyIterator(p):
yield p
while isProxy(p):
More information about the Zope3-Checkins
mailing list