[mod_python] Tutorials, FieldStorage and sys.py. A depressing saga.

Terry MacDonald terry at i3technologies.co.uk
Thu May 22 13:45:55 EST 2003


Hi all,

I come from a hardened UNIX C/C++ programming background and after being
made redundant ages ago and doing nothing much for a good while I felt
my brain needed fodder again and decided to actively dive into the Open
source/Linux world which I have grown to love.  Anyway moving on I have
decided as a first project to build a database backed website for my
local cricket league.  I have chosen Postgres as the database and python
as the programming language (not C anymore, boohoo!) and HTML as the
front end running on an Apache web server. Now the grit.

I'm running Red Hat 9 with the versions of Apache, Python etc that come
with that release.

I have followed a few python tutorials and have had no success with any
in getting a working tutorial at the end.

Problem: I have Apache configured with mod_python. I have a python
script called sample.py and two html files, form.html and template.html
Basically I point the browser at form.html and enter the relevant form
data.  The form then actions the script sample.py and I then get the
following error trace ....

===============================================================================================

Mod_python error: "PythonHandler mod_python.publisher"

Traceback (most recent call last):

  File "/usr/lib/python2.2/site-packages/mod_python/apache.py", line
335, in HandlerDispatch
    result = object(req)

  File "/usr/lib/python2.2/site-packages/mod_python/publisher.py", line
149, in handler
    module = apache.import_module(module_name, req.get_config(), [path])

  File "/usr/lib/python2.2/site-packages/mod_python/apache.py", line
502, in import_module
    module = imp.load_module(mname, f, p, d)

  File "/var/www/html/python/sample.py", line 90, in ?
    form = cgi.FieldStorage()

  File "/usr/lib/python2.2/cgi.py", line 448, in __init__
    elif sys.argv[1:]:

AttributeError: 'module' object has no attribute 'argv'

===============================================================================================
I have looked all around this and am moving towards the fact that I
cannot find sys.py anywhere on my linux system which surely cannot be so
as other modules appear to work fine and pretty much everything imports
this sys.py file.  Why am I getting this error? is their a problem with
the FieldStorage function?

Why can't any python tutorials actually work properly? (they all seem to
have niggly bugs in them)

Anybody know of any good examples/resources for what I want to do.
Preferably working tutorials (;3)

Any help gratefully received!

cheers

Terry






More information about the Mod_python mailing list