Local class variables? (mod_python problem)
Piet van Oostrum
piet at cs.uu.nl
Thu Feb 22 08:19:48 EST 2007
>>>>> Rory Campbell-Lange <rory at campbell-lange.net> (RC) wrote:
>RC> We have a set of classes using static methods to retain reference
>RC> variables between operations. The problem is that the static variables
>RC> are not reset between operations when used through mod_python.
>RC> Although it is possible to reset the class variables between invocations
>RC> of the system, this has the potential of 'wiping out' these variables
>RC> when another user is using the system.
>RC> Is there a way of getting the equivalent of 'local class variables'? In
>RC> other words, a way of making 'print a' and 'print b' below provide the
>RC> same output?
There are several errors in your python code: quite a number of comma's
have to be replaced by semicolons (or newlines), and there is a spurious
comma.
And a and b already print out the same, so it is not clear what you want.
Do you mean that the x and y of the a and b object should be independent?
In that case you should not use static variables but instance variables.
If they have to survive across different HTTP requests you should use
sessions.
--
Piet van Oostrum <piet at cs.uu.nl>
URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4]
Private email: piet at vanoostrum.org
More information about the Python-list
mailing list