Skip to content
This repository

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

Closed
wants to merge 3 commits into from

2 participants

Atsushi Odagiri Chris McDonough
Atsushi Odagiri
aodag commented May 22, 2012

File "/home/aodag/.envs/pyramid/local/lib/python2.7/site-packages/Mako-0.7.0-py2.7.egg/mako/runtime.py", 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.

Atsushi Odagiri
aodag commented May 22, 2012

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

Atsushi Odagiri
aodag commented May 22, 2012

related issues #606, #512

Chris McDonough
Owner
mcdonc commented June 13, 2012

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

Atsushi Odagiri
aodag commented June 14, 2012

I gonna add tests at this week end.

Atsushi Odagiri
aodag commented June 23, 2012

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
Chris McDonough
Owner

This is fixed in master.

Chris McDonough mcdonc closed this September 15, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 3 unique commits by 1 author.

May 22, 2012
Atsushi Odagiri fixed a17b884
Jun 20, 2012
Atsushi Odagiri add test for #607 ff47af2
Jun 23, 2012
Atsushi Odagiri fix on windows 2f6efcb
This page is out of date. Refresh to see the latest.
7  pyramid/mako_templating.py
@@ -28,6 +28,10 @@ class IMakoLookup(Interface):
28 28
     pass
29 29
 
30 30
 class PkgResourceTemplateLookup(TemplateLookup):
  31
+    def __init__(self, *args, **kwargs):
  32
+        super(PkgResourceTemplateLookup, self).__init__(*args, **kwargs)
  33
+        self._adjusted_dict = {}
  34
+
31 35
     """TemplateLookup subclass that handles asset specification URIs"""
32 36
     def adjust_uri(self, uri, relativeto):
33 37
         """Called from within a Mako template, avoids adjusting the
@@ -36,6 +40,8 @@ def adjust_uri(self, uri, relativeto):
36 40
         isabs = os.path.isabs(uri)
37 41
         if (not isabs) and (':' in uri):
38 42
             return uri
  43
+        if relativeto in self._adjusted_dict:
  44
+            return TemplateLookup.adjust_uri(self, uri, self._adjusted_dict[relativeto])
39 45
         return TemplateLookup.adjust_uri(self, uri, relativeto)
40 46
 
41 47
     def get_template(self, uri):
@@ -54,6 +60,7 @@ def get_template(self, uri):
54 60
             # store the generated python code in the mako module_directory or
55 61
             # in the temporary location of mako's modules
56 62
             adjusted = uri.replace(':', '$')
  63
+            self._adjusted_dict[adjusted] = uri
57 64
             try:
58 65
                 if self.filesystem_checks:
59 66
                     return self._check(adjusted, self._collection[adjusted])
5  pyramid/tests/test_mako_templating.py
@@ -397,6 +397,11 @@ def test_render_inheritance(self):
397 397
         result = render('helloinherit.mak', {}).replace('\r','')
398 398
         self.assertEqual(result, text_('Layout\nHello World!\n'))
399 399
 
  400
+    def test_render_inheritance_from_pkg_spec(self):
  401
+        from pyramid.renderers import render
  402
+        result = render('pyramid.tests:fixtures/helloinherit.mak', {}).replace('\r','')
  403
+        self.assertEqual(result, text_('Layout\nHello World!\n'))
  404
+
400 405
     def test_render_inheritance_pkg_spec(self):
401 406
         from pyramid.renderers import render
402 407
         result = render('hello_inherit_pkg.mak', {}).replace('\r','')
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.