cgi POST question

Christopher chris_mk at hotmail.com
Fri Feb 8 17:51:55 EST 2002


Thanks for the great information.  I must admit, I felt like
embarrassed that I didn't see the POST information in urllib.  Then I
realized why:

     I looked through the urllib module BEFORE i realized it was a
POST vs. GET issue.  Had I gone back, it would have been crystal
clear, but, in my mind, I had looked inside and out at the urllib
module so there was no point.  I probably remembered the dictionary
sorting method of urlencode, which is how I thought up making a
dictionary (it seemed a little to easy for me to come up with, now I
know why).  Anyway, for the most part, it works now, there are just a
few little details I need to work out.  Thanks again.

Chris


"Steve Holden" <sholden at holdenweb.com> wrote in message news:<M6C88.96519$KM2.3594308 at atlpnn01.usenetserver.com>...


> You are writing client-side programs, and wanting to retrieve data from the
> intranet web server, correct? The urllib library *is* the one you want ...
> see below.
> 
> As far as the intranet search engine guy goes, his behavior betrays a
> fragile ego and low self-esteem typical of people who aren't really
> comfortable doing what they are doing. The good news is you can ignore hom
> from here on in.
> 
> It's likely he *could* have written his code to work with *either* POST or
> GET, but many people don't know the appropriate techniques. Ironically, in
> ASP and Cold Fusion it's actually *easier* to write CGI scripts this way!
> 
> You are so close you clearly understand Python quite well. See below ...
> 
> >      I did have my boss approve the purchases of a couple networking
> > books and "Python Web Programming" by Steve Holden (<= very good so
> 
> ... and you a clearly a person of discrimination :-) Glad you're enjoying
> the book ...
> 
> Here's an exceprt from the urllib docs:
> 
> """
> urlopen (url[, data])
> ...
> If the url uses the http: scheme identifier, the optional data argument may
> be given to specify a POST request (normally the request type is GET). The
> data argument must in standard application/x-www-form-urlencoded format; see
> the urlencode() function below.
> """
> 
> In other words, as you surmised, you can fill a dictionary with the data you
> want to POST. If you pass the dictionary as a second argument to
> urllib.urlopen(), you do a POST.
> 
> I'd write you some sample code, except you sound like you're quite capable
> of taking it from here. Let us know how it works out.
> 
> regards
>  Steve



More information about the Python-list mailing list