Issue #346 resolved

POST variables shouldn't override GET variables

Anonymous created an issue

In the following case:

<form action="http://www.example.com?param=foo" method="POST"> <input name="param" value="bar"> <input type="submit"> </form>

param should be ['foo', 'bar'], not just 'bar'

Reported by rdelon

Comments (4)

  1. anonymous

    My application wants to distinguish GET parameters from POST parameters too, for the sake of generating a modified query string without submitted form data.

    For instance, one page shows a master/detail database table. My table column headings link to e.g. "?sort=name&reverse=no" and will add or remove other attributes to show different slices of data. I want to preserve those accumulated query settings when the user submits a detail form at the bottom of the page.

    This was easy enough for me to accomplish locally, using a custom filter.

    def beforeRequestBody(self):
      cherrypy.request.getMap = dict(cherrypy.request.paramMap)
    

    I ''do not'' think this should necessarily become core CherryPy behavior, but it might not hurt to document the workaround somewhere.

    BTW, there are of course other ways to skin this cat. I could have used sessions and cookies. But this is a pattern I've enjoyed in earlier PHP projects, and one that seems to work well for my users and their panoply of browsers.

    Actually ''combining'' duplicate GET and POST parameters, I think, would only offer the worst of both worlds. Having POST take precedence makes more sense to me, and is best for my project, assuming it's documented to do that.

  2. Anonymous

    Actually, CP will stay as it is for now. If people want to get the "GET" variables that got overriden they can always parse cherrypy.request.queryString

  3. Log in to comment