Hidden CGI fields in HTML
Oleg Broytmann
phd at emerald.netskate.ru
Tue Aug 10 06:47:27 EDT 1999
On Tue, 10 Aug 1999, Ian Clarke wrote:
> On a related issue, you are clearly experienced in using CGI with
> Python. I couldn't understand why cgi.FieldStorage returned a
> dictionary which contained MiniFieldStorage objects (which must be
> accessed using the .value field) rather than just the data itself. This
> would be much more convenient as I see it. Any ideas?
There are, actually, some more issues on using FieldStorage, for
example, you cannot ask for non-existing field:
v = form["nofield"].value
will raise KeyError. And there is no way to emulate dict.get()...
Oh, yes, I think I know why there is .value! What if your form has more
than one value for some key? Like in the following GET:
http://my.server/my/cgi/prog.py?city=Moscow&city=Paris&city=London
How do you get the value? How do you recognize thera are many values?
Currently, you try to ask for form["city"], if the field exists you try to
ask it for .value, but if the .value does not exists, you know it is a
list:
for f in form["city"]:
print f.value
> Cheers,
>
> Ian.
Oleg.
----
Oleg Broytmann Netskate/Inter.Net.Ru phd at emerald.netskate.ru
Programmers don't die, they just GOSUB without RETURN.
More information about the Python-list
mailing list