[PEAK] Circular class adapters..
Bob Ippolito
bob at redivi.com
Thu Feb 19 18:55:49 EST 2004
On Feb 19, 2004, at 6:39 PM, Phillip J. Eby wrote:
> At 06:34 PM 2/19/04 -0500, Bob Ippolito wrote:
>> I have a use case where I'd like to have a class adapter chain that
>> can
>> be circular in some cases, such as:
--- code that breaks ---
>> How do I make this work? Is it not possible, or is this a bug in
>> PyProtocols? With 0.9.2, I get this nasty traceback:
>
> Ugh. It looks like advising an object (the object itself, as opposed
> to its class) with a circular adapter path doesn't work right. I have
> no idea why, I'll have to investigate further (and add your example to
> the tests.
>
> As a workaround in the meantime, you could give each class a
> metaclass, and tell the metaclasses that their instances provide the
> interfaces, instead of telling the class that the class provides the
> interface.
That's what I figured.. I actually named all of my class interfaces
"IMeta..." in anticipation of this kind of problem, so it will be easy
to track it all down ;)
PyProtocols is great so far though. I decided to port one of my
libraries that depended on twisted.python.components (which I had to
hack in order to make it do what I wanted), and the (theoretically
still working, once this is resolved) code got a whole lot cleaner with
PyProtocols due to neat tricks such as sequenceOf and a much more
flexible design.
-bob
More information about the PEAK
mailing list