[mod_python] using req object with Publisher

Mark Nye mn at momentummedia.com
Tue Jun 15 18:06:26 EDT 2004


Quick question from a newbie modpython user...

Suppose I'm using Publisher to read GET or POST data, but would like to
begin writing back to the browser immediately instead of collecting my
entire page output in a string and returning it all at the end. (Maybe
I'm looping through a long db result set, for example.) Does it make
sense to do something like this:


from mod_python import apache

def myhandler(req, myvar1=None, myvar2=None):
	req.content_type = "text/html"
	req.send_http_header()
	req.write("my html") # of course I'd be doing more here
	raise apache.SERVER_RETURN, apache.OK
	return


Or would anyone suggest a different approach? Thanks!

Mark



More information about the Mod_python mailing list