quetz-mod_python-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary Benson <gben...@redhat.com>
Subject Re: [mod_python] Filter chaining bug
Date Wed, 25 Sep 2002 10:22:26 GMT
On Mon, Sep 16, 2002 at 11:47:23PM -0400, Gregory (Grisha) Trubetskoy wrote:

> OK, I figured out the context-length issue now too. In order to make it
> work, you need to get the latest from CVS, and edit your filter to look
> like this (### indicates new/change):
> 
> from mod_python import apache
> 
> def outputfilter(filter):
>     filter.write("---BEGIN---\n")
>     count = 1
>     while 1:
>         line = filter.readline()
>         if not line:
>             break
>         filter.write("%d: %s" % (count, line))
>         count += 1
>     filter.write("---END---\n")
> 
>     if line is None:     ###
>         filter.close()   ###
> 
>     return apache.OK     ###

Why the "if line is None"?

> The idea is that a filter needs to watch out for an EOS bucket. A read
> operation will return None to indicate an EOS (in all other cases it
> returns an empty string). At this point you must close() the filter.
> (close() simply appends an EOS)

I found a related problem chaining input filters which this will
probably also fix.  Thanks!

Cheers,
Gary

[ gbenson@redhat.com ][ GnuPG 85A8F78B ][ http://inauspicious.org/ ]

Mime
View raw message