Good Grief! Why does this work?

Michael Fraley fraley at usfca.edu
Tue Jan 18 11:18:14 EST 2000


I was trying to run the cgi samples from "Internet Programming with Python"
and kept getting an attribute exception on os.environ. So by trial and error
I changed all references in month.cgi and genCGI.py from os.environ to
cgi.os.environ, and it works with the latest Python version now! (The book
refers to version 1.4). Can anyone tell me why it works? In other words,
what changed about the underlying cgi class, that referring to os.environ
from within genCGI.py no longer works?

sample snippet from genCGI
--------------------------

class cgiBase:
   """Superclass for developing CGI processing objects."""

   # some default parameters
   Content_length_limit = None # set to integer to limit content length
   Form_data_Timeout = 3       # set to None for no timeout

   traceback = 1 # set to zero to disable debug traceback dump.

   def __init__(self, infile=myStdin(sys.stdin), outfile=sys.stdout,
                      environ=cgi.os.environ):
					  #!!
					  #!! NOTE:
					  #!! This is where it bombed on environ=os.environ
					  #!!
       self.infile = infile
       self.outfile = outfile
       self.environ = environ




More information about the Python-list mailing list