[mod_python] Tutorials, FieldStorage and sys.py. A depressing saga.

Radek Kanovsky rk at dat.cz
Fri May 23 09:21:51 EST 2003

On Thu, May 22, 2003 at 07:09:17PM -0500, Dustin Mitchell wrote:

> >     print "Content-Type: text/html\n\n"
> >     print SubResult[0]
> It looks like you're still writing a CGI script, since you're using 'print'.
> If you're taking the time to install and use mod_python, I would suggest
> using the publisher handler or writing your own handlers, as those truly take
> advantage of the status of mod_python as a handler.

You can easily force print statement to work in mod_python. Request
object has method 'write' and it is only method that print statement
calls on destination object. So you can replace sys.stdout with req.

from mod_python import apache
import sys

def handler(req):
    sys.stdout = req
    print 'hello world'
    return apache.OK


Radek Kanovsky

More information about the Mod_python mailing list