[mod_python] Questions for the FAQ - please check and confirm (req.write() and return) also docs update ...

Fabian Fagerholm fabbe at paniq.net
Fri Aug 16 15:17:14 EST 2002


On Fri, 2002-08-16 at 14:51, Mateusz Korniak wrote:
> > --8<--
> > Using req.write() and return statements in the Publisher Handler
> >
> > You may only call req.write() once. If you call it several times, you'll
> > get strange results.
> >
> > If you use req.write() in a function called by the Publisher Handler,
> > you must still return a string at the end of the function. An empty
> > string is not enough.
> > --8<--
> >
> If it's so, mod_python docs 
> (http://www.modpython.org/live/mod_python-2.7.8/doc-html/tut-pub.html)
> needs update becouse I understand it quite opposite to text stated above.
> 
> """
> And last, but not the least, note how all the power of mod_python is still 
> available to this function, since it has access to the Request object. You 
> can do all the same things you can do with a "native" mod_python handler, 
> e.g. set custom headers via req.headers_out, return errors by raising 
> apache.SERVER_ERROR exceptions, write or read directly to and from the client 
> via req.write and req.read, etc. 
> """

Well, it doesn't explicitly say anywhere *how many times* the
req.write() function can be called.

I may very well be wrong, but if my tests are correct, you can only use
req.write() once in a regular mod_python handler. If you're using the
Publisher handler, you can use req.write() once, but then you *have* to
return something at the end of your function, or things won't work.

I agree though that the documentation needs updating. I've sent a
documentation patch (mostly touch-ups and a little rewording here and
there) to Gregory Trubetskoy some time ago, but received no reply.

Cheers,
Fabian





More information about the Mod_python mailing list