Where O Where Did My Data Buffer Go?
Fredrik Lundh
fredrik at pythonware.com
Thu May 3 04:05:08 EDT 2001
Chris Gonnerman wrote:
> The problem here is, since the KBB server is using HTTP POST to send the
> data, your sys.stdout stream is connected back to KBB. THEY don't need
> the data echoed back.
is it just how it looks, or are CGI programmers a special kind of
breed who simply cannot be bothered to set up a test environ-
ment?
if I were a CGI programmer, I'd do something like this:
1) use a stub CGI script to grab some sample data from the
server and save to a file. e.g.
# myposttarget
import os, sys
data = sys.stdin.read(int(os.environ['CONTENT_LENGTH']))
file = open("/temp/data.txt", "w")
file.write(data)
file.close()
print "Content-Type: text/html\n\nok, thanks!"
2) run the script on that sample chunk until it works. if the
script needs more environment variables, set them in the shell:
$ cp /temp/data.txt .
$ ls -l data.txt
$ -rw-r--r-- 1 myself myself 11750 Oct 20 2036 data.txt
$ export REQUEST_METHOD=POST
$ export CONTENT_LENGTH=11750
$ python myposttarget.py <data.txt
exceptions and print statement will appear in the terminal window,
as usual.
3) repeat 1-2 until it appears to work pretty well.
4) deploy.
Cheers /F
More information about the Python-list
mailing list