[Zope3-dev] Interface.Implements module still broken for 2.2 metaclasses

Steve Alexander steve@cat-box.net
Sun, 07 Jul 2002 22:05:54 +0100


Phillip J. Eby wrote:
> 
> I'm not really sure what you're talking about, but I'm pretty sure it 
> has nothing to do with what I'm talking about.  :)  I'm talking about 
> these functions:

I'm talking about those functions too.


> I believe they should read as follows:
> 
> def getImplements(object):
> 
>     if isinstance(object,ClassTypes):
>         if hasattr(object, '__class_implements__'):
>             return object.__class_implements__
>     elif hasattr(object, '__implements__'):
>         return object.__implements__
> 
>     return _typeImplements.get(type(object), None)
> 
> 
> def getImplementsOfInstances(klass, tiget=_typeImplements.get):
>     if isinstance(klass,ClassTypes):
>         if hasattr(klass, '__implements__'):
>             return klass.__implements__
>         else:
>             return None
>     else:
>         return tiget(klass, None)

Ideally, they should, although that still doesn't deal with rolling your 
own metaclass that doesn't derive from a standard class type. I don't 
think there's a particularly elegant way to deal with that, though. yagni.


> This change would only affect proxies which happened to be around 
> classes -- and the change would simply make them *work* on such proxies 
> once isinstance() uses __class__!

Indeed. But in Python2.2.x, isinstance() doesn't use __class__. Right 
now, Zope3 is being developed using Python 2.2.x.

--
Steve Alexander