Life cycle of a mod_python application and scope of global variables
Peter Abel
p-abel at t-online.de
Sat Jan 25 08:39:00 EST 2003
Kyle Yancey <lakeofburningfire at kyle.orgdon'tspamme> wrote in message news:<50f33vofevm3og4bp1ji85atd22bqduv11 at 4ax.com>...
> Okay. Now I feel silly. It doesn't seem to work. I tested the
> following script, and I got an error.
>
> #!/usr/bin/env python
> from mod_python import apache
> i = 1
> def handler(req):
# insert here
global i
# and it will work
> req.content_type = "text/html"
> req.send_http_header()
> if i:
> req.write("Hello World!")
> i = 0
> return apache.OK
>
> The error was local variable referenced before assignment.
> The faq says that this should display the behavior I described.
> http://www.modpython.org/FAQ/faqw.py?req=show&file=faq03.005.htp
> I hope I haven't wasted anyones time. Apologies if I made a mistake.
> This is my first usenet post.
Peter
More information about the Python-list
mailing list