beginner python cgi question

Paolo G. Cantore paolo.cantore at t-online.de
Sat Dec 13 17:23:06 EST 2003


Use 'fields=cgi.FieldStorage(keep-blank-values=1)' and you don't have to 
worry about KeyErrors anymore.

Hope this helps.

Paolo

Brandon Boles wrote:
> Hi folks,
> 
> I am trying to learn python, and have a form processing script giving me
> this error:
> 
> Traceback (most recent call last):
>   File "inquiry", line 16, in ?
>     Address=fields["address"].value
>   File "/usr/local/python2.2/lib/python2.2/cgi.py", line 550, in __getitem__
>     raise KeyError, key
> KeyError: address
> 
> This is the snippet of code the error is referring to:
> 
> ...snip...
> fields=cgi.FieldStorage()
>     if (fields.has_key("name") and fields.has_key("emailaddr")):
>         SenderName=fields["name"].value
>         Address=fields["address"].value
>         City=fields["city"].value
>         State=fields["state"].value
> ...snip...
> 





More information about the Python-list mailing list