follow-up to FieldStorage

Tim Roberts timr at probo.com
Thu Jun 8 01:57:55 EDT 2006


John Salerno <johnjsal at NOSPAMgmail.com> wrote:

>Bruno Desthuilliers wrote:
>> John Salerno a écrit :
>>> If I want to get all the values that are entered into an HTML form and 
>>> write them to a file, is there some way to handle them all at the same 
>>> time, or must FieldStorage be indexed by each specific field name?
>> 
>> AFAIK, FieldStorage is a somewhat dict-like object, but I'm not sure it 
>> supports the whole dict interface. At least, it does support keys(), so 
>> you should get by with:
>> 
>> for k in fs.keys():
>>   print >> myfile, k, ":", fs[k]
>> 
>> But reading the doc may help...
>
>Thanks. The cgi docs don't seem to get into too much detail, unless I 
>wasn't thorough enough. But your method seems like it might work well if 
>I can't find something after another read through.

On the other hand, 45 seconds with the source code shows that "class
FieldStorage" has member functions called "keys()" and "has_key()".

Use the source, Luke.  To me, that's one of the big beauties of Python.
-- 
- Tim Roberts, timr at probo.com
  Providenza & Boekelheide, Inc.



More information about the Python-list mailing list