[Interface-dev] overriding InterfaceClass.__call__ and 3.4.2dev
Jean-Paul Calderone
exarkun at divmod.com
Sun Jan 6 12:46:15 EST 2008
Hey,
I just noticed a change between 3.4.1 and 3.4.2dev relating to the __call__
method of InterfaceClass. If you override it in 3.4.1, it will be used. If
you override it in 3.4.2dev, it won't be.
Is this an intentional change? It breaks a feature of Twisted (in web2). I
believe the relevant code which is no longer being invoked is this:
# Is there a better way to do this than this funky extra class?
_default = object()
class SpecialAdaptInterfaceClass(interface.InterfaceClass):
# A special adapter for IResource to handle the extra step of adapting
# from IOldNevowResource-providing resources.
def __call__(self, other, alternate=_default):
result = super(SpecialAdaptInterfaceClass, self).__call__(other, alternate)
if result is not alternate:
return result
result = IOldNevowResource(other, alternate)
if result is not alternate:
result = IResource(result)
return result
if alternate is not _default:
return alternate
raise TypeError('Could not adapt', other, self)
IResource.__class__ = SpecialAdaptInterfaceClass
You can find this in twisted/web2/iweb.py if you want.
Was this accidental?
Jean-Paul
More information about the Interface-dev
mailing list