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 constructor and store them
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!
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
Hmm,
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
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
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.api_call but
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
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
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 not sure