[Zope-Checkins] CVS: Zope2 - Util.py:1.7 iclass.py:1.11
shane@digicool.com
shane@digicool.com
Fri, 1 Jun 2001 12:16:01 -0400 (EDT)
Update of /cvs-repository/Zope2/lib/python/Interface
In directory korak.digicool.com:/tmp/cvs-serv26203
Modified Files:
Util.py iclass.py
Log Message:
Added support for ExtensionClass to the Interfaces package.
--- Updated File Util.py in package Zope2 --
--- Util.py 2001/01/22 17:29:59 1.6
+++ Util.py 2001/06/01 16:16:00 1.7
@@ -1,6 +1,9 @@
-from iclass import Interface, Class, ClassType, Base, assertTypeImplements, _typeImplements #uuh..
+
+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
--- Updated File iclass.py in package Zope2 --
--- iclass.py 2001/01/16 20:23:01 1.10
+++ iclass.py 2001/06/01 16:16:00 1.11
@@ -15,6 +15,15 @@
import Exceptions
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