cgi post problem
notvalid at hotmail.com
Tue Sep 24 22:01:30 CEST 2002
There was an error in my prior post. See ^^^^
"jano" <notvalid at hotmail.com> wrote in message
news:amq8av$2cum$1 at agate.berkeley.edu...
> "Jeff Davis" <jdavis at empires.org> wrote in message
> news:9aWj9.39314$V7.10439005 at twister.socal.rr.com...
> > Hi,
> > It looks as though you have a lot of code. It might be helpful to try to
> > narrow the problem further by removing a lot of the code unrelated to
> > problem, which appears to be that "keys" does not contain any items.
> > you work that out, then put the other code back in.
> > My first impression is that you have some "weird" form element names
> > because they contain the "/" character. That might be perfectly legal,
> > perhaps the cgi.FieldStorage class does not properly handle such element
> > names, or perhaps it considers such names erroneous.
> > Next, it seems that the line "keys = form.keys()" might be out of
> > with the rest of the code in it's block. Perhaps it's just the way it
> > looks after you copied your code into the post.
> > Regards,
> > Jeff
> Yes, the problem is that keys does not contain any items. The 'weird'
> are not the problem, because i tried it also with regular 1-word names (no
> slashes), with the same results. Also, the keys=form.keys() line is
> properly indented in the code -- it was just a copy/paste problem. Here
> the code again, with the extraneous stuff stripped out:
> import cgitb; cgitb.enable()
> import sys, traceback, cgi
> def main():
> form = cgi.FieldStorage()
> input = form.keys()
> print "Content-type: text/html\n\n"
> print("""<?xml version='1.0' encoding='UTF-8'?>
> <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.1//EN'
> <html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en'>
> print "<p>",keys,"</p>"
# ^^^^ should be 'input' not 'keys', as it is
in my script.
> print "</body></html>"
> if __name__ == "__main__":
> And the form is:
> <form action="http://someurl.com/cgi-bin/updatexml.py" method="post">
> <input type="text" name="Name" size="20" />
> <input type="text" name="PartNumber" size="20" />
> <input type="text" name="Inventory" size="20" />
> <input type="text" name="Cost" size="20" />
> <input type="text" name="WholesalePrice" size="20" />
> <input type="submit" value="Update Records" />
> The script, again, is currently just supposed to return the keys, which I
> expecting to be Name, PartNumber, etc., but it returns only an empty list.
> Any ideas.
More information about the Python-list