[mod_python] Best practices for coding in mod_python?

Jorey Bump list at joreybump.com
Fri Sep 16 15:46:55 EDT 2005


Steve Bergman wrote:

> There are a number of things related to my general approach of which I 
> am uncertain.  e.g. I'm using publisher.  I think that is the right 
> choice, but I'm not sure.  Then there are lots of things involving 
> coding techniques and style of which I am uncertain.  e.g. for a funtion 
> or method to write something to the browser, the return value has to 
> propagate back up to main and get returned from their, right?  Or it 
> just occurred to me I might could use req.write()?  But is that a good 
> thig to do?  If so, when.

When using publisher, it's sufficient to simply return a string. The 
Content-Type is set automatically to text/html if the string looks like 
HTML, text/plain if it doesn't. I've never found the need for 
req.write() with publisher, but I suppose it could be used to avoid 
consuming too much memory when building very large pages.



More information about the Mod_python mailing list