[Twisted-Python] Simple components question - IFoo(IBar(obj)) wont' work, what am I doing wrong?

Michal Pasternak michal at pasternak.w.lub.pl
Sun Jun 20 13:38:43 MDT 2004


Hi,

I've hit a problem with compy, but it seems it's the same for Twisted
Components. What am I doing wrong here? I bet I've overlooked something
really simple, but I'm unable to find out.

---------------------------------------------------------------------------

import twisted.python.components as compy

class IFoo(compy.Interface):
    pass

class IBar(compy.Interface):
    pass

class x: pass

class y(compy.Adapter):
    __implements__ = (IFoo,)
    pass

class z(compy.Adapter):
    __implements__ = (IBar,)
    pass

compy.registerAdapter(y, x, IFoo)
compy.registerAdapter(z, y, IBar)

IBar(IFoo(x()))

---------------------------------------------------------------------------

... this will fail with:

	twisted.python.components.CannotAdapt: <__main__.y instance at 0x80fc0ac> cannot be adapted to <class '__main__.IBar'>.


-- 
m
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
URL: </pipermail/twisted-python/attachments/20040620/7102717d/attachment.sig>


More information about the Twisted-Python mailing list