cgi post problem
jano
notvalid at hotmail.com
Tue Sep 24 16:01:30 EDT 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
your
> > problem, which appears to be that "keys" does not contain any items.
After
> > 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,
but
> > 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
> alignment
> > 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'
names
> 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
is
> the code again, with the extraneous stuff stripped out:
>
> #!/usr/local/bin/python
>
> import cgitb; cgitb.enable()
> import sys, traceback, cgi
>
> def main():
> try:
> 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'
> 'http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd'>
> <html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en'>
> <head>
> <title>test</title>
> </head>
> <body>""")
> print "<p>",keys,"</p>"
# ^^^^ should be 'input' not 'keys', as it is
in my script.
> print "</body></html>"
> except:
> pass
>
> if __name__ == "__main__":
> 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" />
> </form>
>
>
> The script, again, is currently just supposed to return the keys, which I
am
> expecting to be Name, PartNumber, etc., but it returns only an empty list.
> Any ideas.
>
> thanks,
>
> jano
>
>
>
More information about the Python-list
mailing list