From 909dfee23c43709f2aa07942fb633cc740a9a6b3 Mon Sep 17 00:00:00 2001 From: Blaise Laflamme Date: Wed, 22 Aug 2012 10:23:40 -0400 Subject: fixed bug with mixing up asset spec and absolute uri in mako template inheritance --- pyramid/mako_templating.py | 2 ++ pyramid/tests/test_mako_templating.py | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/pyramid/mako_templating.py b/pyramid/mako_templating.py index 489c1f11a..2b09e8d45 100644 --- a/pyramid/mako_templating.py +++ b/pyramid/mako_templating.py @@ -43,6 +43,8 @@ class PkgResourceTemplateLookup(TemplateLookup): if relativeto is not None: relativeto = relativeto.replace('$', ':') if not(':' in uri) and (':' in relativeto): + if uri.startswith('/'): + return uri pkg, relto = relativeto.split(':') _uri = posixpath.join(posixpath.dirname(relto), uri) return '{0}:{1}'.format(pkg, _uri) diff --git a/pyramid/tests/test_mako_templating.py b/pyramid/tests/test_mako_templating.py index aced6c586..97b2c679b 100644 --- a/pyramid/tests/test_mako_templating.py +++ b/pyramid/tests/test_mako_templating.py @@ -499,6 +499,16 @@ class TestPkgResourceTemplateLookup(unittest.TestCase): result = inst.adjust_uri('b', '../a') self.assertEqual(result, '../b') + def test_adjust_uri_not_asset_spec_abs_with_relativeto_asset_spec(self): + inst = self._makeOne() + result = inst.adjust_uri('/c', 'a:b') + self.assertEqual(result, '/c') + + def test_adjust_uri_asset_spec_with_relativeto_not_asset_spec_abs(self): + inst = self._makeOne() + result = inst.adjust_uri('a:b', '/c') + self.assertEqual(result, 'a:b') + def test_get_template_not_asset_spec(self): fixturedir = self.get_fixturedir() inst = self._makeOne(directories=[fixturedir]) -- cgit v1.2.3