[mod_python] Accessing all form fields, empty strings or not

Diener, Edward Edward.Diener at loyaltyworks.com
Fri May 21 12:27:47 EDT 2004


> -----Original Message-----
> From: François Heredero - Top Music SA [mailto:fheredero at topmusic.ch] 
> Sent: Friday, May 21, 2004 11:16 AM
> To: Diener, Edward
> Cc: mod_python at modpython.org
> Subject: RE: [mod_python] Accessing all form fields, empty 
> strings or not
> 
> 
> 
> 
> -----Message d'origine-----
> De : François Heredero - Top Music SA 
> [mailto:fheredero at topmusic.ch] Envoyé : > vendredi, 21. mai 
> 2004 17:13 À : Diener, Edward Objet : RE: [mod_python] 
> Accessing all form fields, empty strings or not
> 
> 
> >i need to access all form fields in my mod_python PSP code, whether 
> >they are empty strings or not.
> I think (but perhaps I'm wrong) empty strings are not 
> supplied by http protocol...
> 
> With the CGI module, I use :
> 
> form = cgi.FieldStorage()
> mytext = float(form.getfirst("text", ""))

Does this tell me whether or not "text" is a form field or not if the return is an empty string ? Three cases:

1) The field "text" is a form field and the value is not empty. I assume theis returns the value.

2) The field "text" is a form field and the value is empty. I assume this returns the default. Does it ?

3) The field "text" is not a form field. What is returned or is an exception thrown ?

I need to distinguish between cases 2) and 3)




More information about the Mod_python mailing list