[Zope-Checkins] CVS: Packages/Interface - Util.py:1.7.8.1 iclass.py:1.11.8.1
Shane Hathaway
shane@digicool.com
Wed, 25 Jul 2001 17:03:13 -0400
Update of /cvs-repository/Packages/Interface
In directory cvs.zope.org:/tmp/cvs-serv20154
Modified Files:
Tag: NR-branch
Util.py iclass.py
Log Message:
Made interfaces compare by equality rather than identity and added a hook
that permits special values in __implements__ attributes.
=== Packages/Interface/Util.py 1.7 => 1.7.8.1 ===
+
+from iclass import Interface, Class, ClassTypes, Base, \
+ assertTypeImplements, _typeImplements #uuh..
from types import FunctionType
+
def impliedInterface(klass, __name__=None, __doc__=None):
"""Create an interface object from a class
@@ -26,7 +29,7 @@
r=[]
t=type(object)
- if t is ClassType:
+ if t in ClassTypes:
if hasattr(object, '__class_implements__'):
implements=object.__class_implements__
else:
@@ -48,7 +51,7 @@
"""
r=[]
- if type(klass) is ClassType:
+ if type(klass) in ClassTypes:
if hasattr(klass, '__implements__'):
implements=klass.__implements__
else: return r
=== Packages/Interface/iclass.py 1.11 => 1.11.8.1 ===
from InterfaceBase import InterfaceBase
+try:
+ from ExtensionClass import Base
+except ImportError:
+ ClassTypes = (ClassType,)
+else:
+ class dummy (Base): pass
+ ClassTypes = (type(dummy), ClassType)
+
+
_typeImplements={}
class Interface(InterfaceBase):
@@ -68,7 +77,7 @@
"""Does the given object implement the interface?
"""
t=type(object)
- if t is ClassType:
+ if t in ClassTypes:
if hasattr(object, '__class_implements__'):
implements=object.__class_implements__
else: implements=Class
@@ -87,7 +96,7 @@
tiget=_typeImplements.get):
"""Do instances of the given class implement the interface?
"""
- if type(klass) is ClassType:
+ if type(klass) in ClassTypes:
if hasattr(klass, '__implements__'):
implements=klass.__implements__
else: return 0