[mod_python] Please help me :)

Michael Gibbs mike at mapvision.com
Fri May 16 14:43:17 EST 2003

Thanks in advance for any guidance you can provide.

Our problem is that we are trying to maintain a counter using a global 
variable. However the script returns different values when multiple browser 
form requests are being submitted. The counter seems to get changed by 
different requests but not as expected. Are we doing something wrong?


This is the HTML form we use to make the mod_python request. 

        <form action="http://localhost/form2" method="POST">
                <input type="submit">

This is the python script (form2.py)

#Why does this script return different values for _count?
#This happens when two browsers are opened and multiple
#forms are submitted. Going back and forth between browsers
#seems to mess up/reset the count on different requests.

from mod_python import apache
_count = 0
def handler(req):
        global _count
        _count += 1
        req.content_type = "text/html"
        req.write('_count = %d' %_count)
        return apache.OK

More information about the Mod_python mailing list