diff options
| author | Chris McDonough <chrism@plope.com> | 2012-08-15 00:30:41 -0400 |
|---|---|---|
| committer | Chris McDonough <chrism@plope.com> | 2012-08-15 00:30:41 -0400 |
| commit | f036f97f00781cf81f8905b6725071f79b31f6c5 (patch) | |
| tree | 253ebda0c7be3b1f9e12a6a072da25082453323f | |
| parent | 735abf49f936cedc845907516a3922cdffa83665 (diff) | |
| parent | 27a2084bbecef4da869da68f0125627355eb3ad1 (diff) | |
| download | pyramid-f036f97f00781cf81f8905b6725071f79b31f6c5.tar.gz pyramid-f036f97f00781cf81f8905b6725071f79b31f6c5.tar.bz2 pyramid-f036f97f00781cf81f8905b6725071f79b31f6c5.zip | |
Merge branch 'master' of github.com:Pylons/pyramid
| -rw-r--r-- | CONTRIBUTORS.txt | 2 | ||||
| -rw-r--r-- | docs/narr/commandline.rst | 4 | ||||
| -rw-r--r-- | docs/narr/introduction.rst | 4 | ||||
| -rw-r--r-- | pyramid/mako_templating.py | 16 | ||||
| -rw-r--r-- | pyramid/tests/test_mako_templating.py | 30 |
5 files changed, 37 insertions, 19 deletions
diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index c3995aaba..a2da7fbfd 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -176,3 +176,5 @@ Contributors - Marc Abramowitz, 2012/06/13 - Jeff Cook, 2012/06/16 + +- Roman Kozlovskyi, 2012/08/11 diff --git a/docs/narr/commandline.rst b/docs/narr/commandline.rst index af53c1f78..3bdf8c5cd 100644 --- a/docs/narr/commandline.rst +++ b/docs/narr/commandline.rst @@ -349,7 +349,7 @@ setting) orderings using the ``ptweens`` command. Tween factories will show up represented by their standard Python dotted name in the ``ptweens`` output. -For example, here's the ``pwteens`` command run against a system +For example, here's the ``ptweens`` command run against a system configured without any explicit tweens: .. code-block:: text @@ -367,7 +367,7 @@ configured without any explicit tweens: 1 pyramid.tweens.excview_tween_factory excview - - MAIN -Here's the ``pwteens`` command run against a system configured *with* +Here's the ``ptweens`` command run against a system configured *with* explicit tweens defined in its ``development.ini`` file: .. code-block:: text diff --git a/docs/narr/introduction.rst b/docs/narr/introduction.rst index b5fa6a9f7..7c0f9223f 100644 --- a/docs/narr/introduction.rst +++ b/docs/narr/introduction.rst @@ -803,7 +803,7 @@ within a function called when another user uses the See also :ref:`add_directive`. Programmatic Introspection --------------------------- +~~~~~~~~~~~~~~~~~~~~~~~~~~ If you're building a large system that other users may plug code into, it's useful to be able to get an enumeration of what code they plugged in *at @@ -831,7 +831,7 @@ callable: See also :ref:`using_introspection`. Python 3 Compatibility ----------------------- +~~~~~~~~~~~~~~~~~~~~~~ Pyramid and most of its add-ons are Python 3 compatible. If you develop a Pyramid application today, you won't need to worry that five years from now diff --git a/pyramid/mako_templating.py b/pyramid/mako_templating.py index d1ee68878..489c1f11a 100644 --- a/pyramid/mako_templating.py +++ b/pyramid/mako_templating.py @@ -1,4 +1,5 @@ import os +import posixpath import re import sys import threading @@ -37,6 +38,16 @@ class PkgResourceTemplateLookup(TemplateLookup): isabs = os.path.isabs(uri) if (not isabs) and (':' in uri): return uri + if not(isabs) and ('$' in uri): + return uri.replace('$', ':') + if relativeto is not None: + relativeto = relativeto.replace('$', ':') + if not(':' in uri) and (':' in relativeto): + pkg, relto = relativeto.split(':') + _uri = posixpath.join(posixpath.dirname(relto), uri) + return '{0}:{1}'.format(pkg, _uri) + if not(':' in uri) and not(':' in relativeto): + return posixpath.join(posixpath.dirname(relativeto), uri) return TemplateLookup.adjust_uri(self, uri, relativeto) def get_template(self, uri): @@ -48,11 +59,6 @@ class PkgResourceTemplateLookup(TemplateLookup): specification syntax. """ - if '$' in uri: - # Checks if the uri is already adjusted and brings it back to - # an asset spec. Normally occurs with inherited templates or - # included components. - uri = uri.replace('$', ':') isabs = os.path.isabs(uri) if (not isabs) and (':' in uri): # Windows can't cope with colons in filenames, so we replace the diff --git a/pyramid/tests/test_mako_templating.py b/pyramid/tests/test_mako_templating.py index 46826d9dd..aced6c586 100644 --- a/pyramid/tests/test_mako_templating.py +++ b/pyramid/tests/test_mako_templating.py @@ -479,6 +479,26 @@ class TestPkgResourceTemplateLookup(unittest.TestCase): result = inst.adjust_uri('a:b', None) self.assertEqual(result, 'a:b') + def test_adjust_uri_asset_spec_with_modified_asset_spec(self): + inst = self._makeOne() + result = inst.adjust_uri('a$b', None) + self.assertEqual(result, 'a:b') + + def test_adjust_uri_not_asset_spec_with_relativeto_asset_spec(self): + inst = self._makeOne() + result = inst.adjust_uri('c', 'a:b') + self.assertEqual(result, 'a:c') + + def test_adjust_uri_not_asset_spec_with_relativeto_modified_asset_spec(self): + inst = self._makeOne() + result = inst.adjust_uri('c', 'a$b') + self.assertEqual(result, 'a:c') + + def test_adjust_uri_not_asset_spec_with_relativeto_not_asset_spec(self): + inst = self._makeOne() + result = inst.adjust_uri('b', '../a') + self.assertEqual(result, '../b') + def test_get_template_not_asset_spec(self): fixturedir = self.get_fixturedir() inst = self._makeOne(directories=[fixturedir]) @@ -499,16 +519,6 @@ class TestPkgResourceTemplateLookup(unittest.TestCase): finally: shutil.rmtree(tmpdir, ignore_errors=True) - def test_get_template_asset_spec_with_uri_adjusted(self): - inst = self._makeOne(filesystem_checks=True) - result = inst.get_template('pyramid.tests$fixtures/helloworld.mak') - self.assertFalse(result is None) - - def test_get_template_asset_spec_with_uri_not_adjusted(self): - inst = self._makeOne(filesystem_checks=True) - result = inst.get_template('pyramid.tests:fixtures/helloworld.mak') - self.assertFalse(result is None) - def test_get_template_asset_spec_missing(self): from mako.exceptions import TopLevelLookupException fixturedir = self.get_fixturedir() |
