[mod_python] basic cgi not working with mp 3.0.3

Jim Peterson jpeterson at ainet.com
Fri Oct 31 12:43:39 EST 2003


Hi,

total newb to python, apache, mod_python, spyce.

running Apache/2.0.47 (Win32) mod_python/3.0.3 Python/2.2.2 Spyce 1.3.11
under Win2K, using ActiveState Python.

i'm trying to use the 'production ready', stable stuff.

Here's the details.  TIA

---------------------------------------------------------------------

Trying to port my CGI app to mod_python. It was blowing up until I 
traced the failure line to mod_python.apache.  I diffed the file against 
a beta version, found a patch there, and applied the patch to my 
apache.py.  The patch stopped the bomb but I'm not getting any form fields.

     #################################
     # original code
     #for k in sav_env:
     #    osenv[k] = env[k]

     # after the patch
     for k in sav_env:
         osenv[k] = sav_env[k]

I don't have any idea if that is relevant.

My test code works in a true CGI environment but not under the mp cgi 
handler.  I'm using Apache aliases to configure both true CGI and mp cgi
against the same directory.

# --------------------------------------------------------
# this configures a conventional CGI setup
ScriptAlias /xcgi-bin/ /Jim/Home/Web/CGI/
<Location /xcgi-bin/ >
     AllowOverride None
     Options +Indexes +ExecCGI
     Order allow,deny
     Allow from all
</Location>
# --------------------------------------------------------
# this configures a mod_python CGI handler, I guess
Alias /cgi-bin/ /Jim/Home/Web/CGI/
<Location /cgi-bin/ >
   SetHandler python-program
   PythonHandler mod_python.cgihandler
   PythonDebug On
</Location>

I invoke my test code with either URL.

I test mod_python handling with url of this form:
/cgi-bin/cgitest.py?fielda='asdf'&fieldb='qwer'

I test true cgi handling with url of this form:
/xcgi-bin/cgitest.py?fielda='asdf'&fieldb='qwer'

Throughout my app I pass values thru the URL/querystring.

Under true CGI, my script gets values in the form fields.  Under mp cgi, 
it gets None.

Here is the CGI script:

# ------------------- cut here --------------------
#!python

# cgitest.py
#
# test cgi port to mod_python cgi handler
#

import cgi
form = cgi.FieldStorage()

# print content type here to enable html rendering of debug form
print "Content-Type: text/html\n\n"

# prints dict of env vars, for debugging
#cgi.print_environ()

# prints dict of form args, for debugging
cgi.print_form(form)

# extract the data from the query string
fielda = form.getvalue('fielda')
fieldb = form.getvalue('fieldb')

# content-type printed above

html = \
'''
<html>
<head>
<title> cgitest.py </title>
</head>
<body>
<hr />
<table>
<tr><td> fielda </td><td> %s </td></tr>
<tr><td> fieldb </td><td> %s </td></tr>
</table>
<hr />
</body>
</html>
'''

print html % (fielda, fieldb)


# ---------------------------------------------------------------
# cgitest.py - end of file
# ---------------------------------------------------------------
#





More information about the Mod_python mailing list