[mod_python] Mod Python Output Filter Behavior

Lee Brown administrator at leebrown.org
Tue Oct 25 12:52:35 EDT 2005


I've been dorking around with writing a mod_python output filter and I have
a question:  In the documentation under Section 4.3, it says:

	"When writing filters, keep in mind that a filter will be called any
time anything upstream requests an IO operation, and
	the filter has no control over the amount of data passed through it
and no notion of where in the request processing it
	is called. For example, within a single request, a filter may be
called once or five times, and there is no way for the
	filter to know beforehand that the request is over and which of
calls is last or first for this request, thought encounter
	of an EOS (None returned from a read operation) is a fairly strong
indication of an end of a request."

The filter I'm working on performs xslt transformations, so it is important
that each entrance into the filter handler gets either the whole xml
document or a well-formed xml fragment.

As a test, I wrote the following filter:

	def outputfilter (filter):
	    filter.write('<p>entering filter</p>')
	    data = filter.read()
	    while data:
	        data = filter.read()
	    filter.write('<p>leaving filter</p>')
	    if data is None:
	        filter.write('<p>closing filter</p>')

Every page I've thrown at this begins with "entering filter" and ends with
"leaving filter" followed by "closing filter."  In other words, the entire
request was pushed through one call to the filter.

Under what circumstances would the comments in Section 4.3 about multiple
calls to the filter actually occur?  So far, I haven't been able to
stimulate that behavior.

Best Regards,
Lee E. Brown
(leebrown at leebrown.org)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20051025/c2e67051/attachment.html

More information about the Mod_python mailing list