[mod_python] Import a module into a variable value

Clodoaldo clodoaldo.pinto.neto at gmail.com
Sat Dec 2 19:34:03 EST 2006


2006/12/2, Graham Dumpleton <grahamd at dscpl.com.au>:
>
> On 02/12/2006, at 9:26 PM, Clodoaldo wrote:
>
> > I'm doing a very light templating in a publisher program.
>
> What features are you after that have made you use publisher in the
> first place? Ie., which of the following is it:
>
> 1. Mapping of URL to different handler files.
>
> 2. Mapping of additional path information to objects within a handler
> file.
>
> 3. Mapping of form arguments to function arguments.
>

1 and 2 make it very easy and convenient.

> I ask as depending on what of the above you are wanting, in
> mod_python 3.3
> there are possibly other ways of doing it which may be more
> attractive and
> also possibly give you more flexibility.

I'm trying the Publisher in a site, carconsumption.com, with one only
page, although a big and treacherous one, which was changed many times
and still needs work.

The way I'm doing it now it good enough *for this site*. As the html
template is loaded in a separate module I just change one byte in the
module and the template is reloaded. But it is still one more file to
change everytime the template is changed.

I'm asking about it because I have bigger plans and want to know how
much I need a real templating system.

>
> One could use your own caching system. An example of one is:
>
>    http://svn.dscpl.com.au/vampire/trunk/software/vampire/markup.py
>
> This one ends up turning the page into a template object for a
> particular
> templating sytsem, but that could be stripped out, leaving it to only
> cache
> the raw page source.
>
> Another page caching system is actually in the mod_python source at
> present and was added to implement the interim module importer in 3.2
> used
> by publisher. This will be removed from mod_python in a future
> version though,
> thus shouldn't be used. You could though go get the original code for
> it and
> use it in your own code. This is at:
>
>    http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/302997
>

Good to know. But if I start adding code like that I had better go all
the way to Cheetah or something.

-- 
Clodoaldo Pinto Neto


More information about the Mod_python mailing list