[Twisted-Python] Python properties and pb.Referenceable...
James Y Knight
foom at fuhm.net
Wed Mar 9 23:23:07 MST 2005
On Mar 9, 2005, at 9:15 PM, Jasper wrote:
> Jasper wrote:
>
>> I'm trying to set a python property on a PB client descended from
>> pb.Referenceable, but it seems that properties don't work on old
>> style classes and that Referenceable is descended from Jellyable, an
>> old style class. Moreover, I see this is still true for 2.0.0a2...
>>
>> Is there any intention of switching to new classes, or should I just
>> hack around this?
>
>
> Turns out that the simple hack of Client( object, pb.Referenceable )
> seems to work. Sorry for the trouble!
You really don't want to do that. Then, if pb.Referenceable ever does
become a new-style class (for example because a new version of python
gets rid of oldstyle classes, or because twisted is changed), then
you'll get an MRO construction error. Always put object last in the
inheritance line.
E.g.:
class Foo: pass
class Bar(object, Foo): pass # Fine
class Foo(object): pass
class Bar(object, Foo): pass # BOOM
James
More information about the Twisted-Python
mailing list