[mod_python] When trying to get cgi.FieldStorage() : AttributeError: 'sys' module has no attribute 'argv'

Alain Tesio alain at onesite.org
Sun May 20 19:39:45 EST 2001


Thanks for the information, but how can I get the GET parameters then ?
The usual cgi variables aren't in os.environ

Alain

----- Original Message -----
From: "Gregory (Grisha) Trubetskoy" <grisha at modpython.org>
To: "Alain Tesio" <alain at onesite.org>
Cc: "ML mod_python" <mod_python at modpython.org>
Sent: Sunday, May 20, 2001 7:17 AM
Subject: Re: [mod_python] When trying to get cgi.FieldStorage() :
AttributeError: 'sys' module has no attribute 'argv'


>
> This is because indeed the sys module has no attribute argv inside
> subinterpreters. This is a "feature not a bug" and is documented somewhere
> in the Python docs.
>
> If you're using the cgi module, just fake the the argv by doing something
> like:
>
> import sys
> sys.argv = []
>
> then cgi module will be happy.
>
> Grisha
>
> On Sun, 20 May 2001, [iso-8859-1] Alain TИsio wrote:
>
> > Hi, I found a message in an archive saying I shouldn't use
> > FieldStorage with publisher
> > http://www.modpython.org/pipermail/mod_python/2001-January/001086.html
> > but I'm not using publisher (or I don't know I am)
> > Any idea what's happening ?
> >
> > Thanks
> > Alain
> >
> > =========== observer_www.py
> > import cgi
> > items=cgi.FieldStorage()
> >
> > =========== output
> >
> > Mod_python error: "PythonHandler observer_www"
> >
> > Traceback (most recent call last):
> >
> >   File "/usr/local/lib/python2.1/site-packages/mod_python/apache.py",
line
> > 176, in Dispatch
> >     module = import_module(module_name, _req)
> >
> >   File "/usr/local/lib/python2.1/site-packages/mod_python/apache.py",
line
> > 340, in import_module
> >     module = imp.load_module(mname, f, p, d)
> >
> >   File "/home/observer/scripts/observer_www.py", line 2, in ?
> >     items=cgi.FieldStorage()
> >
> >   File "/usr/local/lib/python2.1/cgi.py", line 445, in __init__
> >     elif sys.argv[1:]:
> >
> > AttributeError: 'sys' module has no attribute 'argv'
> >
> >
> > _______________________________________________
> > Mod_python mailing list
> > Mod_python at modpython.org
> > http://www.modpython.org/mailman/listinfo/mod_python
> >




More information about the Mod_python mailing list