Hi All,

I'm using Genshi (0.3.6) for my templates. I'm working with an
'application + plugins' model. Where applications and plugins are
separate python packages. The plugins want to use genshi's
<xi:include> directive. In order to allow plugins to xi:include
templates from the application (and other locations) I would, at the
very least, like to parametrize the instantiation of
genshi.template.TemplateLoader such that I can pass in the
`search_path` variable.

I've been staring at:

* http://trac.turbogears.org/ticket/468
* http://trac.turbogears.org/changeset/1728
* The thread in this group with the subject "Template engine
configured before configuration loaded?" [1]

And experimenting with turbgears (trunk r2346).

The obvious thing to do would be to patch
turbogears.view.base.load_engines, adding another genshi variable to
the config vars.

But I can't see how this would ever work. AFAICT, The module level
call to load_engines() in turbogears.view.base forces the global
config to be examined *before* there is any possibility of updating to
config. It does not matter whether the update comes from a .cfg file,
pr is procedural. Any attempt to import turbogears will force a call
to load_engines()

This is ultimately a consequence of the decision to bind widget
templates using __metaclass__ isn't it ?

Ie, this feature requires that the template engines are loaded during
the initial import processing, which in turn precludes application
config values from being able to effect engine instantiation. What gem
of enlightenment am I missing here ?

I think I have three (pragmatic) choices:

1)  implement a thin wrapper around the genshi template engine plugin
and define my own engine prefix. So I get
@expose('apptemplate:some.package.path'). This would let me intercept
the instantiation of genshi.template.TemplateLoader and do what ever I
like in the setuptools entry point I define for 'apptemplate'.

2) Let the standard tg machinery run its course then clobber
turbogears.view.base.engines['genshi'] with my own instantiation of
the standard genshi engine. Running the risk of concequences due to
global tg templates being loaded using one engine instance but
rendered through another.

3). hack my startup script to monkey patch
genshi.template.TemplateLoader so it refers back into my app, then
import turbogears.

None of these are particularly appealing but this is a paid contract
for a customer that explicitly requested the use of TurboGears and
time is of the essence. Before committing to an implementation I'd
like know:

Have I got the wrong end of the stick and missed something obvious ?
Or, is this a genuine issue and what are TuboGears developers thoughts on it ?


Best Regards,

Robin Bryce

[1] 
http://groups.google.com/group/turbogears/browse_frm/thread/e74ef167a4ca08fc/aa588328bbf95c07?lnk=st&q=&rnum=1#aa588328bbf95c07

--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to