CHANGES.txt | ●●●●● patch | view | raw | blame | history | |
pyramid/mako_templating.py | ●●●●● patch | view | raw | blame | history | |
pyramid/tests/test_mako_templating.py | ●●●●● patch | view | raw | blame | history |
CHANGES.txt
@@ -9,6 +9,12 @@ dictionary changed size during iteration`` exception. It no longer does. See https://github.com/Pylons/pyramid/issues/635 for more information. - Backport bug fix from master: - In Mako Templates lookup, check if the uri is already adjusted and bring it back to an asset spec. Normally occurs with inherited templates or included components. https://github.com/Pylons/pyramid/issues/606 https://github.com/Pylons/pyramid/issues/607 1.3.2 (2012-05-19) ================== @@ -691,7 +697,7 @@ predicate argument. See https://github.com/Pylons/pyramid/pull/308 - The AuthTktCookieHelper could potentially generate Unicode headers inappropriately when the ``tokens`` argument to remember was used. See inappropriately when the ``tokens`` argument to remember was used. See https://github.com/Pylons/pyramid/pull/314. - The AuthTktAuthenticationPolicy did not use a timing-attack-aware string pyramid/mako_templating.py
@@ -41,12 +41,17 @@ def get_template(self, uri): """Fetch a template from the cache, or check the filesystem for it In addition to the basic filesystem lookup, this subclass will use pkg_resource to load a file using the asset 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 @@ -69,7 +74,7 @@ return TemplateLookup.get_template(self, uri) registry_lock = threading.Lock() registry_lock = threading.Lock() class MakoRendererFactoryHelper(object): def __init__(self, settings_prefix=None): @@ -136,7 +141,7 @@ registry_lock.acquire() try: registry.registerUtility(lookup, IMakoLookup, registry.registerUtility(lookup, IMakoLookup, name=settings_prefix) finally: registry_lock.release() @@ -159,7 +164,7 @@ def __init__(self, path, lookup): self.path = path self.lookup = lookup def implementation(self): return self.lookup.get_template(self.path) pyramid/tests/test_mako_templating.py
@@ -135,7 +135,7 @@ self._callFUT(info) lookup = self._getLookup() self.assertEqual(lookup.template_args['input_encoding'], 'utf-16') def test_with_error_handler(self): settings = {'mako.directories':self.templates_dir, 'mako.error_handler':'pyramid.tests'} @@ -368,7 +368,7 @@ result = instance.implementation().render_unicode() self.assertTrue(isinstance(result, text_type)) self.assertEqual(result, text_('result')) class TestIntegration(unittest.TestCase): def setUp(self): import pyramid.mako_templating @@ -391,7 +391,7 @@ self.config.add_settings({'reload_templates': True}) result = render('helloworld.mak', {'a':1}).replace('\r','') self.assertEqual(result, text_('\nHello föö\n', 'utf-8')) def test_render_inheritance(self): from pyramid.renderers import render result = render('helloinherit.mak', {}).replace('\r','') @@ -414,7 +414,7 @@ {'a':1}) self.assertEqual(result.ubody.replace('\r', ''), text_('\nHello föö\n', 'utf-8')) def test_render_with_abs_path(self): from pyramid.renderers import render result = render('/helloworld.mak', {'a':1}).replace('\r','') @@ -426,7 +426,7 @@ self.assertEqual( result.implementation().render_unicode().replace('\r',''), text_('\nHello föö\n', 'utf-8')) def test_template_not_found(self): from pyramid.renderers import render from mako.exceptions import TemplateLookupException @@ -464,7 +464,7 @@ inst = self._makeOne(directories=[fixturedir]) result = inst.get_template('helloworld.mak') self.assertFalse(result is None) def test_get_template_asset_spec_with_filesystem_checks(self): inst = self._makeOne(filesystem_checks=True) result = inst.get_template('pyramid.tests:fixtures/helloworld.mak') @@ -478,7 +478,17 @@ self.assertFalse(result is None) 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() @@ -490,7 +500,7 @@ def _makeOne(self, text): from pyramid.mako_templating import MakoRenderingException return MakoRenderingException(text) def test_repr_and_str(self): exc = self._makeOne('text') self.assertEqual(str(exc), 'text') @@ -499,7 +509,7 @@ class DummyLookup(object): def __init__(self, exc=None): self.exc = exc def get_template(self, path): self.path = path return self @@ -513,8 +523,8 @@ raise self.exc self.values = values return text_('result') class DummyRendererInfo(object): def __init__(self, kw): self.__dict__.update(kw)