[mod_python] Mod python sys.stdin

Mike Looijmans mike.looijmans at asml.com
Fri Aug 29 08:56:31 EST 2003


Don't use publisher if you want to read the request (e.g. from a POST)
directly. Publisher will have eaten the whole request before calling your
function.

Use a standard "handler", e.g. this (untested) one lets anyone POST a file
to the system in a cetain path, and report back how large it was and where
it was placed:

BUFSIZE=10240
SOMEBASEPATH = '/usr/local/uploads'

def handler(req):
    req.content_type = 'text/plain'
    destfilename = SOMEBASEPATH + req.path_info
    req.write('Writing: %s\n' % destfilename)
    dstfile = open(destfilename, 'wb')
    srcfile = req
    data = srcfile.read(BUFSIZE)
    c = 0
    while data:
        dstfile.write(data)
        c += len(data)
        data = srcfile.read(BUFSIZE)
    req.write('Wrote: %s bytes\n' % c)
    return apache.OK



-----Original Message-----
From: ktimm <ktimm at var-log.com>
To: mod_python at modpython.org <mod_python at modpython.org>
Date: Thursday, August 28, 2003 6:23 AM
Subject: [mod_python] Mod python sys.stdin


How do I get at sys.stdin with mod_python publisher. I know it's probably
something simple but I'm trying to convert an xml parser that was getting
though a cgi on sys.stdin and it keeps returning that there is no data to
parse.

Thanks
Kevin



-- 
The information contained in this communication and any attachments is confidential and may be privileged, and is for the sole use of the intended recipient(s). Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please notify the sender immediately by replying to this message and destroy all copies of this message and any attachments. ASML is neither liable for the proper and complete transmission of the information contained in this communication, nor for any delay in its receipt.




More information about the Mod_python mailing list