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

Yandle, Hans Hans.Yandle at cingular.com
Thu May 22 09:17:30 EST 2003


I am a newbie myself but would say that it appears you have a problem with
your Python22 install. The sys module is a builtin(internal) module--just
look at os.py. Maybe Redhat has mixed up several versions of Python (such as
1.5.X with 2.X) on the same machine and paths and/or environmental variables
are crossed.

I would suggest running Python standalone (commandline) and perform some
small actions using modules sys and os. Once that is working, build a simple
ordinary straight cgi script using the cgi module and launch it via Apache
/cgi-bin/ folder. Once that works, convert the script to accelerated
mod_python and execute it.

It might be helpful to us if you could provide more details on the Apache
server version (1.3.X or 2.X) and mod_python (2.7.X or 3.X) version you are
running along with the scripts (sample.py, two html files, form.html, and
template.html) you mentioned and references to the tutorial(s) that you feel
do not work. 

Hans

-----Original Message-----
From: Terry MacDonald [mailto:terry at i3technologies.co.uk]
Sent: Thursday, May 22, 2003 8:46 AM
To: mod_python at modpython.org
Subject: [mod_python] Tutorials, FieldStorage and sys.py. A depressing
saga.


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




_______________________________________________
Mod_python mailing list
Mod_python at modpython.org
http://mailman.modpython.org/mailman/listinfo/mod_python
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.modpython.org/pipermail/mod_python/attachments/20030522/31cbf2fb/attachment-0003.htm


More information about the Mod_python mailing list