Guys,

I have a web application and I want to store an object per request so thta
that is available across all classes till end of request.

I am planning  to write the below code in my entry program which is executed
as soon as a request comes:

entry.py
 import threading

 th = threading.currentThread()
 th.service = somemod.Service()

then in other parts of program whereever I want to use service:

 th = threading.currentThread()
 if hasattr(th, 'service'):
   th.service.call_whatever()

I am wondering if I will ever face a problem in this case ? I want to make
sure that since the request till the end the same "service" object is
available and it should not collide with any other request. Since it's a web
application multilple request may come simutaneously.

Is this approach correct ?
_______________________________________________
Tutor maillist  -  [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to