[Web-SIG] Alternative to threading.local, based on the stack

Manlio Perillo manlio_perillo at libero.it
Fri Jul 4 14:17:55 CEST 2008


Iwan Vosloo ha scritto:
> On Fri, 2008-07-04 at 13:42 +0200, Manlio Perillo wrote:
>> Iwan Vosloo ha scritto:
>>> Hi,
>>>
>>> Many web frameworks and ORM tools have the need to propagate data
>>> depending on some or other context within which a request is dealt with.
>>> Passing it all via parameters to every nook of your code is cumbersome.
>>>
>> The natural solution with WSGI is to store objects in the environ 
>> dictionary.
>>
>> In fact in my web applications I always pass the environ dictionary 
>> explicitly to every functions.
> 
> But, this passing of the environ dictionary to every function in you web
> app is exactly what I'd want to avoid?
> 

Yes, but you only need to pass the environ dictionary and not N paramerers.
I think this is a good compromise.

Using thread local storage is not the solution to every problem (as you 
have noted it can not be used when the server handle more then one 
request per thread).

> -i
> 


Manlio Perillo


More information about the Web-SIG mailing list