Life cycle of a mod_python application and scope of global variables

Kyle Yancey lakeofburningfire at kyle.orgdon'tspamme
Fri Jan 24 17:29:34 EST 2003


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):
   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.




More information about the Python-list mailing list