Re: Class extension confusion :(

2010-11-11 Thread r0g
On 11/11/10 19:34, r0g wrote: On 11/11/10 09:34, Peter Otten wrote: r0g wrote: If I understand correctly it may also be possible (and more efficient) to use setattr() to inject the parameters I want into the class as class attributes before use, rather than assigning them to data attributes eve

Re: Class extension confusion :(

2010-11-11 Thread r0g
On 11/11/10 09:34, Peter Otten wrote: r0g wrote: Question B) The only reason I can think of so far is that I don't have a clear picture of how those names came to end up in that scope, it seems very convenient but I'm worried it's black magic of some sort! Could anyone explain or point me to th

Re: Class extension confusion :(

2010-11-11 Thread Peter Otten
r0g wrote: > On 10/11/10 09:52, Peter Otten wrote: >> class PlainAJAXRequestHandler(BaseHTTPRequestHandler): >> def __init__(self, api_call, paths, *args, **kw): >> BaseHTTPRequestHandler.__init__(self, *args, **kw) >> self.api_call = api_call >> self.paths = paths

Re: Class extension confusion :(

2010-11-11 Thread r0g
On 10/11/10 09:52, Peter Otten wrote: class PlainAJAXRequestHandler(BaseHTTPRequestHandler): def __init__(self, api_call, paths, *args, **kw): BaseHTTPRequestHandler.__init__(self, *args, **kw) self.api_call = api_call self.paths = paths Hmm, the plot thickens!

Re: Class extension confusion :(

2010-11-11 Thread Peter Otten
r0g wrote: > On 10/11/10 09:52, Peter Otten wrote: >> r0g wrote: >> >>> I have a subclass of BaseHHTPRequestHandler which uses a dictonary >>> "paths" and a function "api_call" which are defined in the main >>> namespace of the module. I'd rather I was able to pass these object to >>> the construc

Re: Class extension confusion :(

2010-11-10 Thread r0g
On 10/11/10 09:52, Peter Otten wrote: r0g wrote: I have a subclass of BaseHHTPRequestHandler which uses a dictonary "paths" and a function "api_call" which are defined in the main namespace of the module. I'd rather I was able to pass these object to the constructor and store them as data attri

Re: Class extension confusion :(

2010-11-10 Thread Teenan
If memory serves, the following should work fine, as long as your happy for these vars to have the same value for all instances of the RequestHandler (static) MyHandler = PlainAJAXRequestHandler MyHandler.paths = my_paths_var webServer = HTTPServer( server_address, MyHandler) An alternative I've

Re: Class extension confusion :(

2010-11-10 Thread Peter Otten
r0g wrote: > I have a subclass of BaseHHTPRequestHandler which uses a dictonary > "paths" and a function "api_call" which are defined in the main > namespace of the module. I'd rather I was able to pass these object to > the constructor and store them as data attributes "self.paths" and > "self.ap

Class extension confusion :(

2010-11-09 Thread r0g
I have a subclass of BaseHHTPRequestHandler which uses a dictonary "paths" and a function "api_call" which are defined in the main namespace of the module. I'd rather I was able to pass these object to the constructor and store them as data attributes "self.paths" and "self.api_call" but I'm no