From 4c6754fee3114b9d6baca135e75fbd51169c5cf9 Mon Sep 17 00:00:00 2001 From: Blaise Laflamme Date: Tue, 13 Aug 2013 23:24:59 -0400 Subject: fixed mako renderer returning a tuple with a previous defname value in some circumstances --- pyramid/mako_templating.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/pyramid/mako_templating.py b/pyramid/mako_templating.py index 8d4583d82..fa45b671c 100644 --- a/pyramid/mako_templating.py +++ b/pyramid/mako_templating.py @@ -215,12 +215,9 @@ class MakoLookupTemplateRenderer(object): context = system.pop('context', None) if context is not None: system['_context'] = context - if self.defname is None: - if isinstance(value, tuple): - self.defname, value = value - else: - if isinstance(value, tuple): - _, value = value + # tuple returned to be deprecated + if isinstance(value, tuple): + self.defname, value = value try: system.update(value) except (TypeError, ValueError): -- cgit v1.2.3 From 894d304ed5f738746195f956a204f7e551e1cb5b Mon Sep 17 00:00:00 2001 From: Blaise Laflamme Date: Tue, 13 Aug 2013 23:25:23 -0400 Subject: added mako renderer test --- pyramid/tests/test_mako_templating.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pyramid/tests/test_mako_templating.py b/pyramid/tests/test_mako_templating.py index f607a5497..a57ac0aaa 100644 --- a/pyramid/tests/test_mako_templating.py +++ b/pyramid/tests/test_mako_templating.py @@ -416,6 +416,21 @@ class MakoLookupTemplateRendererTests(Base, maybe_unittest()): self.assertEqual(result, text_('result')) self.assertEqual(lookup.values, {'_context':1}) + def test_call_with_defname_with_tuple_value_twice(self): + lookup = DummyLookup() + instance1 = self._makeOne('path', 'defname', lookup) + result1 = instance1(('defname1', {}), {'context':1}) + self.assertEqual(lookup.deffed, 'defname1') + self.assertEqual(result1, text_('result')) + self.assertEqual(lookup.values, {'_context':1}) + instance2 = self._makeOne('path', 'defname', lookup) + result2 = instance2(('defname2', {}), {'context':2}) + self.assertNotEqual(lookup.deffed, 'defname1') + self.assertEqual(lookup.deffed, 'defname2') + self.assertEqual(result2, text_('result')) + self.assertEqual(lookup.values, {'_context':2}) + + def test_call_with_nondict_value(self): lookup = DummyLookup() instance = self._makeOne('path', None, lookup) -- cgit v1.2.3 From 96df8d5c511ec6742873b3e86d3c875899dc77e3 Mon Sep 17 00:00:00 2001 From: Blaise Laflamme Date: Tue, 13 Aug 2013 23:51:17 -0400 Subject: added deprecation warning for mako tuple --- pyramid/mako_templating.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pyramid/mako_templating.py b/pyramid/mako_templating.py index fa45b671c..c07ee227f 100644 --- a/pyramid/mako_templating.py +++ b/pyramid/mako_templating.py @@ -2,6 +2,7 @@ import os import posixpath import sys import threading +import warnings from zope.interface import ( implementer, @@ -217,6 +218,14 @@ class MakoLookupTemplateRenderer(object): system['_context'] = context # tuple returned to be deprecated if isinstance(value, tuple): + warnings.warn( + 'Using a tuple in the form (\'defname\', {}) to render a ' + 'Mako partial will be deprecated in the future. Use a ' + 'Mako template renderer as documented in the "Using A ' + 'Mako def name Within a Renderer Name" chapter of the ' + 'Pyramid narrative documentation instead', + DeprecationWarning, + 3) self.defname, value = value try: system.update(value) -- cgit v1.2.3 From 24c932646ace774d39341bc52cfa01ef84eeede5 Mon Sep 17 00:00:00 2001 From: Blaise Laflamme Date: Wed, 14 Aug 2013 00:04:46 -0400 Subject: added bug fix to changes --- CHANGES.txt | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 0479e3011..84f3aaf54 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -133,6 +133,10 @@ Features Bug Fixes --------- +- Fixed a Mako renderer bug returning a tuple with a previous defname value +in some circumstances. See https://github.com/Pylons/pyramid/issues/1037 for +more information. + - Make the ``pyramid.config.assets.PackageOverrides`` object implement the API for ``__loader__`` objects specified in PEP 302. Proxies to the ``__loader__`` set by the importer, if present; otherwise, raises @@ -270,7 +274,7 @@ Features @subscriber(SomeOtherEvent) def asubscriber(event): pass - + And you wanted to use a subscriber predicate:: @subscriber([SomeEvent, SomeContextType], mypredicate=True) @@ -344,7 +348,7 @@ Features @subscriber([SomeContextType, SomeEvent]) def asubscriber(event): - # bzzt! you'll be getting the context here as ``event``, and it'll + # bzzt! you'll be getting the context here as ``event``, and it'll # be useless Existing multiple-argument subscribers continue to work without issue, so you @@ -614,7 +618,7 @@ Bug Fixes https://github.com/Pylons/pyramid/issues/606 https://github.com/Pylons/pyramid/issues/607 -- In Mako Templates lookup, check for absolute uri (using mako directories) +- In Mako Templates lookup, check for absolute uri (using mako directories) when mixing up inheritance with asset specs. https://github.com/Pylons/pyramid/issues/662 @@ -833,13 +837,13 @@ Backwards Incompatibilities * ``registerAdapter``, use ``pyramid.config.Configurator.registry.registerAdapter`` instead. - * ``registerSubscriber``, use + * ``registerSubscriber``, use ``pyramid.config.Configurator.add_subscriber`` instead. - * ``registerRoute``, use + * ``registerRoute``, use ``pyramid.config.Configurator.add_route`` instead. - * ``registerSettings``, use + * ``registerSettings``, use ``pyramid.config.Configurator.add_settings`` instead. - In Pyramid 1.3 and previous, the ``__call__`` method of a Response object -- cgit v1.2.3 From 3de54e3009f624f3c3dabe531fbcc25483368fe4 Mon Sep 17 00:00:00 2001 From: Blaise Laflamme Date: Wed, 14 Aug 2013 00:10:03 -0400 Subject: fixed line indentation --- CHANGES.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 84f3aaf54..76522695a 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -134,8 +134,8 @@ Bug Fixes --------- - Fixed a Mako renderer bug returning a tuple with a previous defname value -in some circumstances. See https://github.com/Pylons/pyramid/issues/1037 for -more information. + in some circumstances. See https://github.com/Pylons/pyramid/issues/1037 + for more information. - Make the ``pyramid.config.assets.PackageOverrides`` object implement the API for ``__loader__`` objects specified in PEP 302. Proxies to the -- cgit v1.2.3