[modwsgi] Re: Can't get environ in __init__

2011-10-20 Thread Gnarlodious
I don't want a class created on each request, I want to get environ when initializing my application. For example: if environ['SERVER_ADDR']=='127.0.0.1': # If localhost, add a Dev menu These values would stay the same throughout my session. Now how can I get these values in __init__? Is there

Re: [modwsgi] Re: Can't get environ in __init__

2011-10-20 Thread Joonas Lehtolahti
On Thu, 20 Oct 2011 17:21:37 +0300, Gnarlodious gnarlodi...@gmail.com wrote: I don't want a class created on each request, I want to get environ when initializing my application. For example: if environ['SERVER_ADDR']=='127.0.0.1': # If localhost, add a Dev menu These values would stay the

Re: [modwsgi] Re: Can't get environ in __init__

2011-10-20 Thread Graham Dumpleton
Correct. The WSGI specification doesn't cover any way of providing application initialisation information. You will need to provide that manually somehow and no way it can be passed in automatically. Graham On 21 October 2011 01:35, Joonas Lehtolahti godjo...@gmail.com wrote: On Thu, 20 Oct

Re: [modwsgi] Re: Can't get environ in __init__

2011-10-19 Thread Joonas Lehtolahti
class Tester(object): def __init__(self): self.environ=environ def __call__(self, environ, startResponse): startResponse(200 OK, [(Content-Type, text/plain)]) ApplicationName=self.environ['mod_wsgi.process_group']

[modwsgi] Re: Can't get environ in __init__

2011-10-19 Thread Gnarlodious
So... instead of __call__ I should use __iter__, which must return at least one yield string. That clarifies it, I think. I'll experiment with it over the next few days. -- Gnarlie http://Gnarlodious.com -- You received this message because you are subscribed to the Google Groups modwsgi

Re: [modwsgi] Re: Can't get environ in __init__

2011-10-19 Thread Graham Dumpleton
The original document you referenced has three examples of how to have a class created on each request with environ captured in constructor. Look for those examples where it uses: application = Application Graham On 20 October 2011 05:36, Gnarlodious gnarlodi...@gmail.com wrote: So...