[mod_python] Try # 2: Mod_python.publisher behavior - sending .py file to browser - Still !

Graham Dumpleton grahamd at dscpl.com.au
Sun May 7 04:16:52 EDT 2006

On 07/05/2006, at 5:24 PM, Geoff Skerrett wrote:

> I created a very simple program index.py program to help me  
> understand the
> behavior.
> It is as follows;
> ### Begin index.py
> def index(req):
> 	req.write("I am in index()")
> def bar(req):
> 	req.write("I am in bar()")

Whoops. Quite obvious really. You must use:

   def index(req):
	return "I am in index()"
   def bar(req):
	return "I am in bar()"

When you you use req.write(), the headers are automatically flushed,  
so the
setting of req.content_type by mod_publisher after the published  
returns has no affect.

In other words, if you are going to use req.write(), you must set  


More information about the Mod_python mailing list