Commit d9eb0444 authored by Shane Hathaway's avatar Shane Hathaway

Added support for ExtensionClass to the Interfaces package.

parent 0aa0a900
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 @@ def objectImplements(object, tiget=_typeImplements.get):
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 @@ def instancesOfObjectImplements(klass, tiget=_typeImplements.get):
"""
r=[]
if type(klass) is ClassType:
if type(klass) in ClassTypes:
if hasattr(klass, '__implements__'):
implements=klass.__implements__
else: return r
......
......@@ -15,6 +15,15 @@ from types import FunctionType, ClassType
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 @@ class Interface(InterfaceBase):
"""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 @@ class Interface(InterfaceBase):
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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment