[mod_python] OutputFilter example

Dan W. dwmp at opti.cgi.net
Mon Jan 5 22:50:57 EST 2004


I don't see why two calls would make sense.  On the second call the headers 
have already been sent, so I can't modify those and the body has already 
been sent as well and the very first call to filter.read() returns 
None.  On the other hand, if I do filter.close() when I receive empty 
string from filter.read() then I only end up with one call to my output 
filter and everything works normally.

-Dan



At 09:58 PM 1/5/2004 -0500, you wrote:

>I think this is the way it's supposed to work.
>
>On Mon, 5 Jan 2004, Dan W. wrote:
>
> >
> > In the example of the output filter in the 3.1.2b documentation the last
> > lines seem to indicate that filter.close() should only be called if
> > filter.read() returns None.  I paired up an output filter this evening with
> > the mod_python.psp handler and I was getting an empty string on the last
> > filter.read() for every request.  The example code only calls
> > filter.close() if the last read result is None.  Not calling filter.close()
> > on the first call caused the output filter handler to be called a second
> > time.  The second time around, it tried to read from filter.read() and got
> > None, therefore calling filter.close() and ending the cycle.  Should this
> > be normal behavior or should I be calling filter.close() when filter.read()
> > returns empty string as well?
> >
> > My server config:
> >
> >      AddHandler mod_python .psp
> >      PythonHandler mod_python.psp | .psp
> >      PythonOutputFilter mypackage.mymodule TESTFILTER
> >      AddOutputFilter TESTFILTER .psp
> >
> >
> > -Dan
> >
> > _______________________________________________
> > Mod_python mailing list
> > Mod_python at modpython.org
> > http://mailman.modpython.org/mailman/listinfo/mod_python
> >



More information about the Mod_python mailing list