durusmail: quixote-users: GET, POST, QUERY_STRING and FieldStorage
GET, POST, QUERY_STRING and FieldStorage
2003-03-22
2003-03-22
2003-03-25
Re: GET, POST, QUERY_STRING and FieldStorage
2003-03-25
2003-03-25
GET, POST, QUERY_STRING and FieldStorage
lucio
2003-03-25
>
>
>Of course a simple dictionary isn't good enough for handling
>"?name=dennis&name=arthur&age=37", which could be the result of an
>accident in form design, deliberate form design, a multiple selection
>list, or a broken/malicious client.  The standard 'cgi' module's
>FieldStorage class handles this in maybe the worst possible way, by
>providing values of unpredictable type.
>
But returning always a list would be very unconfortable.

name = request.form['name'][0] # and ugly

And, as long as we are playing with python internals(ptls), we could do
it the fdscript way,  using non deterministic programming:

 >>> foo = request.form['name']
 >>> foo

 >>> print "My name is:", name
My name is: Lucio
My name is: Otherguy
 >>> t = "Hello, " + name
 >>> t


I have no idea how it could be done, and anyways, i dont really mean it.

So back to the original question, if not unpredicatable and not always
lists, how should request.form return its values? Maybe a container
class that when applied str() would return str(self[0])?

Lucio.


reply