[mod_python] HTML filtering

Scott Chapman scott_list at mischko.com
Thu Mar 27 15:14:16 EST 2003


I am VERY interested in this.  If you can make a copy of it available to 
experiment with, I'd appreciate it.

My vote is "Yes" on GPL action here!

Scott

On Thursday 27 March 2003 2:25 pm, Dmitry Orlov wrote:
Hi Scott,

Thanks for the tip, but I've looked at all kinds of templating engines,
and they all pretty much do the same thing, albeit in a wide variety of
ways. The commonalities are:

1. you have to manually put in bits of code to change values of
attributes and query string variables, and

2. designers who use wysiwyg tools like Dreamweaver are at a loss if you
give them a marked-up HTML file to edit.

The idea behind ours is that lots of common-sense stuff just happens
automatically. For example, if there is an <input type="text"
name="foo"> and request.foo happens to be "bar", the engine spits out
<input type="text" name="foo" value="bar"> without being asked. Likewise
with <a href="something.com?foo"> - it gets rewritten to <a
href="something.com?foo=bar"> without the programmer having to do
anything.

We've been using this engine with good results for about 4 years now, on
lots of sites, like http://designjet.hp.com/. It's built into a couple
of our legacy frameworks, but should be relatively easy to reuse;
reasonably recent docs are available at
http://www.integratis.org/dfp.html.

I am leaning in the direction of making it into a GPL'ed Python module
that can be plugged into mod_python as an output filter. But I don't
know how much interest there would be. OSDN/Sourceforge/Freshmeat don't
seem effective as far as gauging interest.

That's why I am sort of spamming this list (just this once, I promise!)
If you think you might be interested in trying it out, or know of anyone
who might be, please let me know. If a bunch of people tell me "Yes,
I'll try it", then that's probably all the push I need to start coding.

-Dmitry

Scott Chapman wrote:
> You might want to look at Spyce (http://spyce.sourceforge.net/) also.  It
> allows you to embed Python in HTML.
>
> Scott
>
> On Wednesday 26 March 2003 8:32 am, Dmitry Orlov wrote:
> 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
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://www.modpython.org/mailman/listinfo/mod_python





More information about the Mod_python mailing list