[Zope3-checkins] CVS: Zope3/src/zope/interface - implements.py:1.4

Philipp von Weitershausen philikon@philikon.de
Thu, 10 Apr 2003 11:43:17 -0400


Update of /cvs-repository/Zope3/src/zope/interface
In directory cvs.zope.org:/tmp/cvs-serv14022/interface

Modified Files:
	implements.py 
Log Message:
Instead of comparing the classes and checking with isinstance, we check
whether InterfaceClass is in the method resolution order, because

  a) it works with classes extending InterfaceClass (they will have
     InterfaceClass in their __mro__)
  
  b) also, this is faster ;)


=== Zope3/src/zope/interface/implements.py 1.3 => 1.4 ===
--- Zope3/src/zope/interface/implements.py:1.3	Tue Jan  7 07:14:53 2003
+++ Zope3/src/zope/interface/implements.py	Thu Apr 10 11:43:16 2003
@@ -64,8 +64,7 @@
     # yet remain compatible with earlier versions of python.
     implements_class = getattr(implements, '__class__', None)
 
-    if implements_class == InterfaceClass or \
-       isinstance(implements, InterfaceClass):
+    if InterfaceClass in implements_class.__mro__:
         return visitor(implements)
     elif implements == CLASS_INTERFACES:
         klass = getattr(object, '__class__', None)