[mod_python] Post and Get vars together?

Graham Dumpleton grahamd at dscpl.com.au
Mon Mar 14 17:44:18 EST 2005


Tobiah wrote ..
> Hi, I noticed that I don't seem to be able to
> get POST vars and GET vars at the same time
> out of the req.form object as passed by the
> Publisher Handler.  I am used to PHP, where
> they are available separately.  Is this possible,
> and if not, would it be possible with the Default
> Handler (not using the publisher).

Even if using handler and not publisher, you would normally use
util.FieldStorage from mod_python, which is what publisher uses
anyway. Ie., it would behave the same way.

What you can do though is try cgi.FieldStorage from the standard
Python cgi module to see if it supports the PHP style of allowing
GET style form parameters at the same time as POST ones.

If cgi.FieldStorage does work, you might put up a report at:

  http://issues.apache.org/jira/browse/MODPYTHON

as an "improvement", that util.FieldStorage in mod_python be
enhanced along the lines of cgi.FieldStorage to support such an
ability.

BTW, do not comment in util.FieldStorage code:

""" The classes below are a (almost) a drop-in replacement for the
    standard cgi.py FieldStorage class. They should have pretty much the
    same functionality.
    
    These classes differ in that unlike cgi.FieldStorage, they are not
    recursive. The class FieldStorage contains a list of instances of
    Field class. Field class is incapable of storing anything in it.
    
    These objects should be considerably faster than the ones in cgi.py
    because they do not expect CGI environment, and are
    optimized specifically for Apache and mod_python.
"""

Thus, you might see some slowdown in performance.

Graham


More information about the Mod_python mailing list