FORM data in cgi
Mike Meyer
mwm at mired.org
Thu Oct 13 19:42:49 EDT 2005
More information about the Python-list mailing list
Thu Oct 13 19:42:49 EDT 2005
- Previous message (by thread): ANNOUNCE: Python interface for making telephone calls using Voicent Gateway
- Next message (by thread): FORM data in cgi
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"jponiato" <jponiato at chartermi.nojunk> writes: > Greetings. > An HTML form submits it's data to a python cgi script on my server. This script accepts this POST data, and uses urllib.urlopen() to call a different cgi script (on an external server), passing this same data. I'm using cgi.FieldStorage() to create a mapping of the FORM data, then using urllib.urlencode() to turn it back into form data for urlopen(). > Question - is there a more efficient way to do this? Yes. But the question you should be asking is "Is there an easier way to do it that's worth doing?" Unless you're passing around files, or really huge forms, the amount of time you spend doing decoding and encodinng the form data will be pretty trivial. Unless you're really pressed for cycles, why bother fixing it? And if you're really pressed for cycles, you should start by instrumenting things to make sure that you're optimizing something that will do you some good. Anyway, the general idea is to skip cgi.FieldStorage, and parse the request yourself. You'll have to deal with the headers. But you can just grab the post data with a read(). I'm not sure you can use urllib to send pre-encoded POST data; you'll have to check that yourself. If not, you'll have to do the HTTP request processing by yourself. That's not hard, though. <mike -- Mike Meyer <mwm at mired.org> http://www.mired.org/home/mwm/ Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
- Previous message (by thread): ANNOUNCE: Python interface for making telephone calls using Voicent Gateway
- Next message (by thread): FORM data in cgi
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list