Interpackage Mako inheritance in Pyramid 1.1 vs 1.0

51 views
Skip to first unread message

Wyatt Baldwin

unread,
Jul 30, 2011, 3:54:03 PM7/30/11
to pylons-...@googlegroups.com
With Pyramid 1.0, I could inherit from a template in another package using the standard Mako syntax:

# Paste config file:
mako.directories = package_A:templates pacakge_B:templates

# templates/layout.mako in package_A
<html>
    ...
</html>

# templates/app.mako in package_B
<inherit file="/layout.mako" />
...

When I upgraded to Pyramid 1.1, I started getting a template lookup error. I had to change file="/layout.mako" to file="package_A:templates/layout.mako" to get it working again.

Has anyone else run into this issue?

Wyatt Baldwin

unread,
Aug 2, 2011, 1:49:12 AM8/2/11
to pylons-...@googlegroups.com

 I dug into this a bit, and I think I see what's happening. I'm not sure if this a bug in Pyramid or in my configuration.

First of all, in my `main` function, I have a line like this:

    config.override_asset('my_framework', 'my_app')

In other words, I've specified that *all* assets in the framework package should be overridden by assets in the app package.

My mako.directories setting initially looks like this: ['my_app:templates', 'my_framework:templates']. The first time a template is rendered, these asset specs are converted to absolute filesystem paths.

The problem is that 'my_framework:templates' is converted to '/path/to/my_app/templates' due to the override above, and the directory list used for template lookup ends up containing duplicate paths pointing to my_app's templates directory.

Of course, the net effect of all this is that if a template isn't found in the app package, the Mako template lookup machinery never checks to see if the framework might contain the template.
Reply all
Reply to author
Forward
0 new messages