Local class variables? (mod_python problem)
Diez B. Roggisch
deets at nospam.web.de
Fri Feb 23 09:02:54 EST 2007
> 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.
Diez
More information about the Python-list
mailing list