[mod_python] HTML filtering

Dmitry Orlov dorlov at banta-im.com
Wed Mar 26 11:32:41 EST 2003


I've started looking into switching some sites that use Python through
cgi to mod_python. The sites work via HTML filtering, sort of like PHP,
with bits of Python stuck inside HTML files. I tried to look for docs
that would show how I could set up such a scheme for mod_python, but
haven't found anything (yet).

Currently, we configure Apache using ScriptAlias and Action directives,
so that any request for a .html file within a certain Location gets
piped through the cgi which runs Python via an HTML filter.

The HTML filter coded in C/flex. It does variable substitution for
things like {$foo}, runs Python snippets between <?python and ?> tags a
la PHP, and a bunch of other nifty things, like form pre-population.

This scheme works quite well, and is fast if one uses fastcgi, but is a
bit complicated. I am hoping to simplify it using mod_python while
retaining the excellent performance.

I am thinking that the ideal drop-in replacement scheme would be to make
our HTML filter into a Python module, and call it via an output filter.
But how do I set it up so that mod_python runs for .html files instead
of .py files?

-Dmitry



More information about the Mod_python mailing list