[mod_python] Best practices for coding in mod_python?

akonsu akonsu at gmail.com
Fri Sep 16 16:55:15 EDT 2005


2005/9/16, Steve Bergman <steve at rueb.com>:
> 
> 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
>
judging from its source code, publisher handler is just a wrapper
around your code. all it does is finds your file and invokes a
procedure on it. not much extra functionality. so i would say it is up
to the developer to decide whether it is worthwhile to use it.
>
> 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
>
right, just like in any programming code, if the return value is
generated in some internal procedure, it has to be propagated to the
caller and returned from there.
>
> just occurred to me I might could use req.write()?  But is that a good
> thig to do?  If so, when.
> 
so, returning a string from your procedure to the publisher handler
which then will use req.write to output it versus just using req.write
yourself is a question of how clear you want your code to be. it does
not really matter which method you use. this is similar to a question
of whether your code can generate console output in just one single
place or whether it can be done everywhere in the code.
>
> It's not so much that I have not found ways to do what I want to do, but
> I'm uncomfortable with my style and technique.
>
hope this helps...



More information about the Mod_python mailing list