summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBlaise Laflamme <blaise@laflamme.org>2012-08-22 10:23:40 -0400
committerBlaise Laflamme <blaise@laflamme.org>2012-08-22 10:23:40 -0400
commit909dfee23c43709f2aa07942fb633cc740a9a6b3 (patch)
treeaf2f62c1b2bd80738b8fec94fd1f7158286ab85f
parentb9b4657e79e7e1ed1f0c79bf82c3fe19a0ab5687 (diff)
downloadpyramid-909dfee23c43709f2aa07942fb633cc740a9a6b3.tar.gz
pyramid-909dfee23c43709f2aa07942fb633cc740a9a6b3.tar.bz2
pyramid-909dfee23c43709f2aa07942fb633cc740a9a6b3.zip
fixed bug with mixing up asset spec and absolute uri in mako template inheritance
-rw-r--r--pyramid/mako_templating.py2
-rw-r--r--pyramid/tests/test_mako_templating.py10
2 files changed, 12 insertions, 0 deletions
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])