[mod_python] using req object with Publisher

Mark Nye mn at momentummedia.com
Wed Jun 16 15:32:04 EDT 2004


Quick modpython newbie question...

Suppose that I'm using Publisher to collect GET or POST data, but that I
want to begin writing back to the browser immediately, instead of
collecting my output in a string and returning it all at the end. (Maybe
I'm looping through a large 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 have more here
	raise apache.SERVER_RETURN, apache.OK
	return

Or might anyone suggest a better approach? Thanks!

best,
Mark Nye

Momentum Media
Ithaca, NY



More information about the Mod_python mailing list