Hi,
I was wondering if its possible to use persistent variables in a mod_python handler.
What I mean is a variable that is stored between two user requests, for example a counter that increments every time a user access the page, although that is not what I intend to do.
I tried this here:
but it always just writes out:Code:global count def handler(req): from mod_python import apache try: # Should be execute if variable is defined in memory req.write("count: " + str(count)) count = count + 1 except Exception, e: # If variable is not bound an exception is thrown, then this is called count = 0 req.write("count: " + str(count)) return apache.OK
count: 0
but not count: 0 after the first time, count: 0 and count: 1 after the next and count: 1 and count: 2 after the third ... as I want.
If any one knows how to do that please let me know. I want to try to use something like this for setting up an environment (reading stuff from database and stuff like that) just one time and store it in a persistent variable for fast access for subsequent requests.
Best regards,
Magnus

.


