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

Graham Dumpleton grahamd at dscpl.com.au
Sun Apr 9 21:07:25 EDT 2006


Jay wrote ..
> 
> Hi,
> 
> I've spent a lot of time in the past embedding latex into HTML pages.
> All of the solutions I've come across fall short in one way or 
> another.
> 
> I've spent the last few days knocking together a little mod_python
> app that utilizes memcached to do as-needed rendering of latex
> embedded in HTML.
> 
> If anyone is interested, feel free to take a look and send comments.
> 
> http://www.meangrape.com/htmlatex

BTW, change:

	<Location /your/directory>
		PythonPath ['/var/www/python/htmlatex']+sys.path
		PythonDebug Off
		PythonOutputFilter htmlatex HTMLATEX
		AddOutputFilter HTMLATEX .htmlx
	</Location>


to:

	<Location /your/directory>
		PythonPath ['/var/www/python/htmlatex']+sys.path
		PythonDebug Off
		PythonOutputFilter htmlatex HTMLATEX
		AddOutputFilter HTMLATEX;CONTENT_LENGTH .htmlx
	</Location>

and you will get correct amended content length header added back in.

This works because you buffer up data and write it in one go. Thus the
CONTENT_LENGTH output filter is able to recalculate content length
for you.

You could also have added it yourself by going:

    if s is None:
        temp_doc = ''.join(temp_doc)
        data = main(temp_doc)
        filter.req.set_content_length(len(data))
        filter.write(data)
        filter.close()	

Graham


More information about the Mod_python mailing list