[mod_python] getting started

Anthony Barker anthony_barker at hotmail.com
Wed Oct 8 17:22:15 EST 2003


I was wondering how to get started processing an html form.

1) is there something equivalent to Apache::PerlRun?

"This module does not cache compiled scripts between runs.
A script is loaded and compiled freshly each time it is requested.
However, Apache::PerlRun still avoids the overhead of starting a new Perl
interpreter for each CGI script, so it's faster than traditional Perl CGI
scripting but slower than Apache::Registry or vanilla Apache API modules."

2) How would mod_python enable this simple script?

#!/usr/bin/python2
import cgi, sys, string
sys.stderr = sys.stdout
print "Content-type: text/html\r\n"

out1 = """
<HTML>
<HEAD><TITLE>Info Form</TITLE></HEAD>
<BODY BGCOLOR = white>
<H3>Please, enter your name and age.</H3>
<TABLE BORDER = 0>
<FORM METHOD = post ACTION = "t3.cgi">
<TR><TH>Name:</TH><TD>
<INPUT type = text name = "name"></TD>
</TABLE>
<INPUT TYPE = hidden NAME = "action" VALUE = "display"
<INPUT TYPE = submit VALUE = "Enter">
</FORM>
</BODY>
</HTML>"""

form = cgi.FieldStorage()
if form.has_key("action"):
    if form.has_key("name"):
        print "hello " + form["name"].value
else:
    print out1

_________________________________________________________________
Instant message in style with MSN Messenger 6.0. Download it now FREE!  
http://msnmessenger-download.com



More information about the Mod_python mailing list