James Y Knight wrote:
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
Actually, I prefer it to blow up to help remember when to stop using this ugly comment requiring hack.. I have absolute control over the version of Python and Twisted I'm using, and so the worst that can happen is that I'll have to change a single line of code when and if I upgrade to such a version of Twisted or Python. -Jasper