pyramid override_asset and mako template lookup

63 views
Skip to first unread message

Robert Forkel

unread,
Nov 4, 2011, 8:01:18 AM11/4/11
to pylons-discuss
Hi all,
I just ran into a clash between my intuition and the reality of
pyramid's support for mako templates: I assumed that override_asset
would also work for mako's template lookups, but this doesn't seem to
be the case. While it is still possible to get the functionality I
need by specifying multiple mako.directories and referencing other
mako templates within templates not using asset specs, I wonder
whether the mako template lookup shouldn't respect overridden assets?
regards
robert

Robert Forkel

unread,
Nov 4, 2011, 8:10:29 AM11/4/11
to pylons-discuss
i should note that asset overrides are taken into account for the
template specifications given in view configurations, which is
probably what started me thinking it would also work within templates.

> --
> You received this message because you are subscribed to the Google Groups "pylons-discuss" group.
> To post to this group, send email to pylons-...@googlegroups.com.
> To unsubscribe from this group, send email to pylons-discus...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
>
>

Wyatt Baldwin

unread,
Nov 4, 2011, 3:38:32 PM11/4/11
to pylons-...@googlegroups.com
I had some issues with this in Pyramid 1.1 and also found it to be counter-intuitive (see here), but my thinking was opposite yours with regard to how asset overrides should be applied to `mako.directories`.

In Pyramid 1.1, the problem was that the asset spec was resolved lazily the first time a template was rendered, which meant that my asset override was applied to the `mako.directories` setting even though I didn't want it to be. In my mind, `mako.directories` should have already been fully resolved by the time I called `config.override_asset()`.

I fixed this by resolving the asset specs myself at configuration time (i.e., in my `main` function) before the `override_asset()` call.

If it now works the way you describe, I might consider it to be fixed.

I guess the big question is, should asset overrides be applied to settings and, if so, at what point during the configuration process? Because you might want to do some base configuration without any overrides applied and then say, ok, from here on out apply this override.
Reply all
Reply to author
Forward
0 new messages