Change in cgi module's handling of POST requests

Joshua Kugler joshua at joshuakugler.com
Thu Feb 12 16:22:15 EST 2009


Bob Kline wrote:

> [Didn't realize the mirror didn't work both ways]
> 
> We just upgraded Python to 2.6 on some of our servers and a number of our
> CGI scripts broke because the cgi module has changed the way it handles
> POST requests.

> When the 'action' attribute was not present in the form 
> element on an HTML page the module behaved as if the value of the
> attribute was the URL which brought the user to the page with the form,
> but without the query (?x=y...) part.

This does not make sense.  Can you give an example?  When you POST, the
attributes are not appended to the URL, but form encoded.

> Now FieldStorage.getvalue () is 
> giving the script a list of two copies of the value for some of the
> parameters (folding in the parameters from the previous request) instead
> of the single string it used to return for each.

There is a function call to get only one value.  I think it's get_first() or
some such.

Well, the CGI module hasn't had many changes.  There was this bug fix a few
months back:

http://svn.python.org/view?rev=64447&view=rev

Diff to previous:
http://svn.python.org/view/python/trunk/Lib/cgi.py?rev=64447&r1=58218&r2=64447

For all revisions:
http://svn.python.org/view/python/trunk/Lib/cgi.py?rev=67528&view=log

It is possible that by fixing a bug, they brought the behavior in line with
what it *should* be.  Or maybe the browser behavior changed?  The server
does not care about an "action" attribute.  That only tells the browser
where to send the data.  It is possible the browser did not properly format
a request when there was no "action" attribute. Can you provide more
details?

j




More information about the Python-list mailing list