[mod_python] mod_python / memcahced for on-the-fly rendering oflatex in html

Jay jayed at meangrape.com
Sun Apr 9 20:55:29 EDT 2006

On Sun, Apr 09, 2006 at 08:41:17PM -0400, Graham Dumpleton wrote:
> Cute. Nice to see someone actually using output filters for something.

When I ran across output filters, I thought to myself -- "this is what
I've been looking for".

> BTW, you say:
>   With this setting, htmlatex filters all outgoing html that end in .htmlx.  I'd
>   like to have it handle .html files, but right now, it chokes on plain HTML
>   without any equations.  More mod_python study is needed.
> In what way does it choke on HTML with no LaTeX elements? Is this really
> a mod_python issue as your line about more mod_python study being
> required seems to suggest?

The original setup was:

PythonOutputFilter	htmlatex	HTMLATEX
AddOutputFilter		HTMLATEX	.html

HTML files with latex worked fine.  The symptoms stayed the same
after bouncing the server so it probably wasn't some quirk.
A plain old HTML file (http://www.meangrape.com/htmlatex/index.html
for instance) caused the following error:

[error] [client] htmlatex
htmlatex: Traceback (most recent call last):, referer:

[error] [client] htmlatex
htmlatex:   File
"/usr/lib/python2.3/site-packages/mod_python/apache.py", line 187, in
FilterDispatch\n    object(filter), referer: http://www.meangrape.com/

[error] [client] htmlatex
htmlatex:   File "/var/www/python/htmlatex/htmlatex.py", line 107, in
outputfilter\n    filter.write(main(temp_doc)), referer:

[error] [client] htmlatex
htmlatex: TypeError: Argument to write() must be a string, referer:

The applicable code is:

    if not hasattr(filter.req,'temp_doc'): 
        filter.req.temp_doc = []
	# If content-length ended up wrong, Gecko browsers truncated
	# data
	if "Content-Length" in filter.req.headers_out:
	    del filter.req.headers_out["Content-Length"]
	temp_doc = filter.req.temp_doc

	s = filter.read()
	while s:
	   s = filter.read()

    if s is None:
        temp_doc = ''.join(temp_doc)
-->     filter.write(main(temp_doc))

I'm quite inclined to believe that I've something misconfigured, or my
code is weak. I highly doubt that it's a mod_python problem per se.


More information about the Mod_python mailing list