Skip to content


Subversion checkout URL

You can clone with
Download ZIP


adjusted uri used by inheriting templates, caused lookup error. #607

wants to merge 3 commits into from

2 participants


File "/home/aodag/.envs/pyramid/local/lib/python2.7/site-packages/Mako-0.7.0-py2.7.egg/mako/", line 732, in _lookup_template
raise exceptions.TemplateLookupException(str(e))
TemplateLookupException: Cant locate template for uri u'demo$templates/layout.mak'

Template Uri shourd be original uri, when loading that.


I found that bug in pyramid 1.3.2.
On pyramid 1.3, template inheritance works fine.


related issues #606, #512


Is there any way to provide a test which fails without the fix?


I gonna add tests at this week end.


I tested on windows, and fix that.

tested and passed

  • Ubuntu 12.04 64bit, python2.7.3
  • Ubuntu 12.04 64bit, python3.2.3
  • Windows7 64bit, python 2.7.2 64bit

This is fixed in master.

@mcdonc mcdonc closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 22, 2012
  1. @aodag


    aodag committed
Commits on Jun 20, 2012
  1. @aodag

    add test for #607

    aodag committed
Commits on Jun 23, 2012
  1. @aodag

    fix on windows

    aodag committed
This page is out of date. Refresh to see the latest.
7 pyramid/
@@ -28,6 +28,10 @@ class IMakoLookup(Interface):
class PkgResourceTemplateLookup(TemplateLookup):
+ def __init__(self, *args, **kwargs):
+ super(PkgResourceTemplateLookup, self).__init__(*args, **kwargs)
+ self._adjusted_dict = {}
"""TemplateLookup subclass that handles asset specification URIs"""
def adjust_uri(self, uri, relativeto):
"""Called from within a Mako template, avoids adjusting the
@@ -36,6 +40,8 @@ def adjust_uri(self, uri, relativeto):
isabs = os.path.isabs(uri)
if (not isabs) and (':' in uri):
return uri
+ if relativeto in self._adjusted_dict:
+ return TemplateLookup.adjust_uri(self, uri, self._adjusted_dict[relativeto])
return TemplateLookup.adjust_uri(self, uri, relativeto)
def get_template(self, uri):
@@ -54,6 +60,7 @@ def get_template(self, uri):
# store the generated python code in the mako module_directory or
# in the temporary location of mako's modules
adjusted = uri.replace(':', '$')
+ self._adjusted_dict[adjusted] = uri
if self.filesystem_checks:
return self._check(adjusted, self._collection[adjusted])
5 pyramid/tests/
@@ -397,6 +397,11 @@ def test_render_inheritance(self):
result = render('helloinherit.mak', {}).replace('\r','')
self.assertEqual(result, text_('Layout\nHello World!\n'))
+ def test_render_inheritance_from_pkg_spec(self):
+ from pyramid.renderers import render
+ result = render('pyramid.tests:fixtures/helloinherit.mak', {}).replace('\r','')
+ self.assertEqual(result, text_('Layout\nHello World!\n'))
def test_render_inheritance_pkg_spec(self):
from pyramid.renderers import render
result = render('hello_inherit_pkg.mak', {}).replace('\r','')
Something went wrong with that request. Please try again.