[mod_python] mod_python Live examples

Nic Ferrier nferrier at tapsellferrier.co.uk
Thu Aug 19 01:45:10 EDT 2004

Byron Ellacott <bje at apnic.net> writes:

> That's what I do.  GET operations fetch a view, which consists of any 
> number of Python modules each returning an XML fragment (or throwing a 
> redirection exception).  Those fragments are combined into a document, 
> which is passed to the defined translator for the view.  Currently, the 
> only translator type I have is XSLT.
> POST operations call a single module to handle the operation requested, 
> which returns an XML fragment and a view to display.  The engine then 
> redirects (currently by calling, soon by 303ing) to the view, including 
> the POSTed XML result in the output.
> But I work on it in fits and starts, with little free time these days. 
> There are a number of problems to solve:
>   * XHTML is pretty useless as an output language, since IE does not 
> support it - but you can output HTML with XSLT;
>   * All the XML processing is slower than most other templating methods, 
> and so caching at various levels is important; and
>   * Since I'm processing an entire XML document through a translation, I 
> cannot send a partial response to a client, and this vastly changes the 
> user's impression of responsiveness.

Your architecture sounds more complicated than the one I use. I have
business methods that deliver XML. The XML gets transformed into HTML
(or not) by particular mod_python handlers. It's a very code based

In my architecture, there is no aggregation of XML from collections of
business methods (though there could be if it was pragmatic). There is
no special 'view' definition. There is no need for a pluggable
translation layer. The mod_python parts of the architecture are *very*

And note that XSLT doesn't have to be slow; there's quite a lot of
research going into improving speed. The pipelining approach has
already been taken:


but in general it's far easier to build DOMs. DOM building is
expensive in terms of memory: but at least that it a known. Just add
more memory  /8->

In a RESTfull application you could also just add another server.

> The last one is the most significant.  If the browser cannot render a 
> partial page, the user will feel that the application is slower to 
> respond, sometimes significantly so, even if it's actually faster to 
> load the complete page.  This is a major stumbling block to using XSLT 
> for whole-page translations.

Hmmm... but unless you translate the whole page you don't know that
there won't be an error that you should signal with 500 (or

This is true for all templating applications, those that return data
before translation completion are inherently weak.

Python doesn't have 'standard' XSLT support yet... but when it does it
will be possible to pass DOMs around instead of XML character
streams. That will speed things up considerably.

And even though there is no 'standard' XSLT support I still think
mod_python is a *very* good tool for RESTfull applications like this.


More information about the Mod_python mailing list