bottlepy / bottle

bottle.py is a fast and simple micro-framework for python web-applications.
http://bottlepy.org/
MIT License
8.37k stars 1.46k forks source link

(minor) request.params overlaps form and query data #1219

Closed mindforger closed 4 years ago

mindforger commented 4 years ago

upfornt, my knowledge in python and how to understand multidict is limited, so i will start with my test implementation to describe what i observed, maybe i am just doing it wrong

in html <form action="/test?myparam=querycontent" [...] <button id="test" name="myparam" value="postcontent"> [...]

in my bottle

querydata = request.params.get("myparam") formdata = request.forms.get("myparam") print(querydata) print(formsdata)

i know it would be unusual to put query parameters into the action of a form but i discovered by accident that the forms data are also reflected in request.params which looks odd to me so i tried this out and if someone MAY find a use for such a post action it can not be handled with bottle, one would have to parse the request to grab the correct query manually

OR i totally missed how to find the right "myparam" in the params multidict :) so please enlighten me in this case

defnull commented 4 years ago

That's the idea of params. See this table: https://bottlepy.org/docs/dev/tutorial.html#html-form-handling

mindforger commented 4 years ago

Now i got it, thx