Re: Late initialization using __getattribute__

2008-09-04 Thread Bruno Desthuilliers
bukzor a écrit : On Sep 3, 1:02 pm, Bruno Desthuilliers [EMAIL PROTECTED] wrote: bukzor a écrit : (snip) Thanks for the reply. Just to see it not work, I tried to remove __getattribute__ from LateInitMixIn, but couldn't get it to work. ??? Sorry, I don't get what you mean... Since you said

Re: Late initialization using __getattribute__

2008-09-04 Thread bukzor
so unfortunately I think I need to use __getattribute__ to do this. I'm doing all this just to make the connection not actually connect until used. I may be dumb, but I don't get how this is supposed to solve your problem. But anyway : there's a known design pattern for what you're

Re: Late initialization using __getattribute__

2008-09-04 Thread Carl Banks
On Sep 4, 12:36 pm, bukzor [EMAIL PROTECTED] wrote: so unfortunately I think I need to use __getattribute__ to do this. I'm doing all this just to make the connection not actually connect until used. I may be dumb, but I don't get how this is supposed to solve your problem. But

Re: Late initialization using __getattribute__

2008-09-04 Thread bukzor
I'd like to be able to do something like this: class SuperCursor(FeatureOneMixIn, FeatureTwoMixin, ..., VanillaCursor): pass Why does it have to look like that?  A good programmer lets the code look however it has to look to most effectively do it's job. With a proxy, the base class

Re: Late initialization using __getattribute__

2008-09-04 Thread Bruno Desthuilliers
bukzor a écrit : so unfortunately I think I need to use __getattribute__ to do this. I'm doing all this just to make the connection not actually connect until used. I may be dumb, but I don't get how this is supposed to solve your problem. But anyway : there's a known design pattern for what

Re: Late initialization using __getattribute__

2008-09-04 Thread Carl Banks
On Sep 4, 3:38 pm, bukzor [EMAIL PROTECTED] wrote: The point of using a mixin is to not limit myself to inheriting from VanillaCursor. I want to put this on top of various subclasses of the vanilla cursor, like TimeLimitedCursor or RetryingCursor. I have four other mixins that operate this

Late initialization using __getattribute__

2008-09-03 Thread bukzor
I want to make a MixIn class that waits to initialize its super- classes until an attribute of the object is accessed. Not generally useful, but desirable in my case. I've written this, and it works, but would like to take any suggestions you guys have. I've commented out the delattr call because

Re: Late initialization using __getattribute__

2008-09-03 Thread Bruno Desthuilliers
bukzor a écrit : I want to make a MixIn class that waits to initialize its super- classes until an attribute of the object is accessed. Not generally useful, but desirable in my case. I've written this, and it works, but would like to take any suggestions you guys have. You shouldn't mess with

Re: Late initialization using __getattribute__

2008-09-03 Thread bukzor
On Sep 3, 12:19 pm, Bruno Desthuilliers [EMAIL PROTECTED] wrote: bukzor a écrit : I want to make a MixIn class that waits to initialize its super- classes until an attribute of the object is accessed. Not generally useful, but desirable in my case. I've written this, and it works, but

Re: Late initialization using __getattribute__

2008-09-03 Thread Bruno Desthuilliers
bukzor a écrit : (snip) Thanks for the reply. Just to see it not work, I tried to remove __getattribute__ from LateInitMixIn, but couldn't get it to work. ??? Sorry, I don't get what you mean... My Base class is a C class (_mysql.connection from MySQLdb) that sometimes segfaults if you try

Re: Late initialization using __getattribute__

2008-09-03 Thread bukzor
On Sep 3, 1:02 pm, Bruno Desthuilliers [EMAIL PROTECTED] wrote: bukzor a écrit : (snip) Thanks for the reply. Just to see it not work, I tried to remove __getattribute__ from LateInitMixIn, but couldn't get it to work. ??? Sorry, I don't get what you mean... Since you said

Re: Late initialization using __getattribute__

2008-09-03 Thread Michele Simionato
On Sep 4, 12:26 am, bukzor [EMAIL PROTECTED] wrote: I'm trying to optimize my number of connections by not fully initializing (read: not connecting) my connection until it's used in some way. I had the same use case and I solved with a simple property. Here is the code I have for pymssql: