[mod_python] Can't get post vars using Publisher Handler

Tobiah toby at rcsreg.com
Fri Aug 27 09:39:38 EDT 2004


I'm trying to use the FieldStorage class from
the Publisher Handler... is that possible?

I can read GET vars fine, but not POSTs.
I looked at the source for FieldStorage,
and it basically tries to read
req.headers_in['content-length'] bytes using
req.read(), but the read is always empty.

Here is a boiled-down example of what I'm
trying to do:

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


from mod_python import util
from mod_python import apache

def index(req):

         req.content_type = "text/html"
         req.send_http_header()

         doc = """
                 <HTML>
                 <HEAD>
                         <TITLE>post example</TITLE>
                 </HEAD>
                 <BODY>
                 <FORM ACTION=index.py METHOD=POST NAME=foo>
                 <INPUT TYPE=text NAME=poster>
                 <INPUT TYPE=submit NAME=submitter VALUE='GO!'>
                 <BR>
         """

         f = util.FieldStorage(req, 1)
         for e in f.list:
                 doc += "Element: %s, Value %s<BR>" % (e.name, e.value)

         doc += """
                 </FORM>
                 </BODY>
                 </HTML>
         """

         return doc

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

Thanks for any help.

Tobiah


More information about the Mod_python mailing list