Local class variables? (mod_python problem)

Rory Campbell-Lange rory at campbell-lange.net
Fri Feb 23 11:38:10 EST 2007


On 23/02/07, Diez B. Roggisch (deets at nospam.web.de) wrote:
> > It is not desirable for the class variable to keep incrementing outside
> > of invocations of '__main__', as is the case when it is loaded under
> > mod_python under apache2 on linux.
> > 
> 
> I'm still not clear on what you want to accomplish. In the end it boils down
> to who is supposed to share that information in the variables, or in other
> words: which scope has it.
> 
> Is it per request? Then using some thread-local storage would be in order,
> or "abusing" a possible request-object.
> 
> Is it per user, over several requests? Then you need a session-mechanism.
> 
> Is it per application, for several users, over several requests? Then your
> approach is ok, but needs guarding against concurrrent access using
> threading.Lock for example. However, I presume that is not the desired
> usecase, from what I can extract from your posts I presume it's case two.

Many thanks for your reply. The use case is per request, and I would be
grateful to learn more about thread-local storage.

Kind regards
Rory

-- 
Rory Campbell-Lange 
<rory at campbell-lange.net>
<www.campbell-lange.net>



More information about the Python-list mailing list