Mod-python problem

Bob Parnes bp at sam.localdomain
Wed Feb 27 22:35:22 EST 2002


Hello,

I am having difficulty with the FieldStorage class in 
the mod-python module for apache. I cannot get 
util.FieldStorage() to return anything. If someone could 
point me to an example, I would be grateful.

Just in case I am missing something obvious, the following 
is my test code, for a linux system:
---------------------------------------------

#!/usr/bin/env python

from mod_python import util

class clTest:
    def cltest(self, req, formDict):
        res = '<html><head></head><body>'
        res += '<table align=center>'
        res += '<TR><TH colspan=2>Welcome to the \
            mod-python class test'
        res += '<TR><TD colspan=2>keys: %s' \
		    % formDict.keys()
        res += '<form method=post>'
        res += '<TR><TD>Name <TD><input type=text \
            name="name">'
        res += '<TR><TD>Phone <TD><input type=text \
            name="phone">'
        res += '<TR><TD colspan=2 align=center> \
            <input type=submit name=submit>'
        res += '</form></table></body></html>'
        return res

def main(req):
    formDict = util.FieldStorage(req)
    cl = clTest()
    return cl.cltest(req, formDict)
--------------------------------------------

The form displays as I expect it to, but when I enter 
data and press the submit button, formDict remains 
empty

In contrast, the following code in the cgi-bin directory 
works fine:
---------------------------------------------

#!/usr/bin/env python

import cgi

class clTest:
    def cltest(self, formDict):
        res = 'Content-Type: text/html\n\n'
        res += '<html><head></head><body>'
        res += '<table align=center>'
        res += '<TR><TH colspan=2>Welcome to the \
            mod-python class test'
        res += '<TR><TD colspan=2>keys: %s' \
		    % formDict.keys()
        res += '<form method=post>'
        res += '<TR><TD>Name <TD><input type=text \
            name="name">'
        res += '<TR><TD>Phone <TD><input type=text \
            name="phone">'
        res += '<TR><TD colspan=2 align=center> \
            <input type=submit name=submit>'
        res += '</form></table></body></html>'
        return res

def main():
    formDict = cgi.FieldStorage()
    cl = clTest()
    print cl.cltest(formDict)

if __name__ == '__main__':
    main()
--------------------------------------------	

Thanks in advance for any help or references.

Bob Parnes

-- 
Bob Parnes
rparnes at megalink.net



More information about the Python-list mailing list