CGI: Assign FieldStorage values to variables

Chris Angelico rosuav at gmail.com
Wed Aug 17 05:25:03 EDT 2011


On Wed, Aug 17, 2011 at 10:06 AM, Gnarlodious <gnarlodious at gmail.com> wrote:
> I get a construct like this:
>
> form=FieldStorage(None, None, [MiniFieldStorage('name1', 'Val1'),
> MiniFieldStorage('name2', 'Val2'), MiniFieldStorage('name3', 'Val3')])
>
> when I need to assign the variable name2 the value Val2

You can probably do this with some kind of list comprehension, but I
recommend against it, if this has come from a web form. You do NOT
want end users having the power to set variables. Keep it in a
separate object (such as 'form') such that you must always be explicit
about fetching form data. PHP has learned the risks; here's a decent
summary:

http://www.php.net/manual/en/security.globals.php

Chris Angelico



More information about the Python-list mailing list