Way to distinguish between POST and GET data in Python CGIs?

Simon Willison cs1spw at bath.ac.uk
Wed Aug 27 20:44:40 EDT 2003


Hi all,

I've been experimenting with Python CGIs, and more recently mod_python. 
The FieldStorage class used by Python's cgi module and mod_python's 
utility library allows form data sent by a user's browser to be easily 
accessed, but doesn't appear to provide any method of distinguishing 
between data sent by POST and data sent by GET.

Coming from PHP, where these two types of input are available in 
separate $_POST and $_GET arrays, this is causing me some concern. 
Although I do not see this as a security flaw (I will still be 
validating data no matter where it came from) I have always preferred to 
restrict some types of input to GET and others to POST - for example, 
any script that modifies data on the server in some way should use POST 
rather than GET to prevent accidental modifications being caused by 
user's bookmarking strange pages.

Does anyone know of a cgi style module for Python that can distinguish 
between the two types of data? I'd also be interested in finding out the 
reasons this functionality was excluded from the cgi module in the first 
place.

Best regards,

Simon Willison







More information about the Python-list mailing list