Inconsistency in CGI Documentation????

Maan M. Hamze mmhamze at pleiades.net
Tue Aug 21 16:19:12 EDT 2001


"Ignacio Vazquez-Abrams" <ignacio at openservices.net> wrote in message
news:mailman.998413112.10035.python-list at python.org...
> On Tue, 21 Aug 2001, Maan M. Hamze wrote:
>
> >  [snip]
> > Ok!  I am not going to provide this argument.  So, the Text Input
element
> > that I left empty and had not provided a vlaue for should NOT make it
into
> > FieldStorage() if user does not type some characters in it.  Right?  I
tried
> > it.  It does not make it.
> > Even if I provide a value of " " (is " " an empty string??)
>
> No. If a string contains even just a single whitespace character it is not
> empty.
>
That is what I want and that is what I expected.
<form with some action=key_list.py>
<input type=text name=FirstName value = " ">    note that the value is a
white space
<submit goes here>
</form>
key_list.py:
 print "content-type:text/heml\n\n"
 form = cgi.FieldStorage()
 for name in form.keys():
    print "Input: " + name + " value: " + form[name].value + "<BR>"

I am not getting the Text element with value = " " in the list

Also, if I set value of Text input element into "" (empty) or if I do not
include value at all in the form, but then enter a space from the form
itself and submit; again I am not getting the text element in the list.
If you are saying that it should be there if there is a white space, I'll
just try it again.

> > 2.  BUT, read on:
> >
> >  [snip]
> >
> > Of interest is:   if form.has_key("firstname")  and
form["firstname"].value
> > != ""
> > How come we are checking for the key AND that the vlaue of the key is
not
> > ""?  Is not that code assuming that a non-empty string can be included
in
> > FieldStorage() without using keep_blank_values?  Thus a contradiction
with
> > what point 1. has to say about it?
>
oppps....  I meant to say:  Is not that code assuming that AN EMPTY string
can be included in FieldStorage() without using keep_blank_values?

> It depends on the browser. I'm not certain what the RFCs or W3C has to say
> about it, but a browser usually does not send to the server information
about
> a field that has no value. That doesn't necessarily mean that a browser
may
> not try to pull that stunt, however :) So the code makes sure that if
there IS
> a value, that it is not empty.
>
Ok!  I see.  So PythonWin documentation states the ideal situation, and the
bit of code above ensures that this ideal situation is enforced.  This makes
sense now.  So the issue that remains is why I am not getting in the list of
keys the Text Input element that has a white space which is NOT empty.
However, I'll try again.
I have by the way Python 2.1; Win NT 4 workstation, and IE 5.5.
Thanks,
Maan





More information about the Python-list mailing list