From 15ac15d60e788c087facfce85b1ead9f7dd4c3ae Mon Sep 17 00:00:00 2001 From: Michael Merickel Date: Fri, 22 Jul 2011 11:55:19 -0500 Subject: Fixed formatting fail. --- docs/narr/hooks.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/narr/hooks.rst b/docs/narr/hooks.rst index 2a6414e1f..985934736 100644 --- a/docs/narr/hooks.rst +++ b/docs/narr/hooks.rst @@ -601,6 +601,9 @@ to make sure the object implements every attribute and method outlined in :class:`pyramid.interfaces.IResponse` and you'll have to ensure that it's marked up with ``zope.interface.implements(IResponse)``: +.. code-block:: python + :linenos: + from pyramid.interfaces import IResponse from zope.interface import implements -- cgit v1.2.3 From fa360e3b5dbc9866325a6a2c39279cb11f6b2918 Mon Sep 17 00:00:00 2001 From: Shane Hathaway Date: Fri, 22 Jul 2011 21:09:06 -0600 Subject: Signed contributor agreement --- CONTRIBUTORS.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index cdc011f87..4e9d944ea 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -142,3 +142,5 @@ Contributors - Michael Merickel, 2011/5/25 - Christoph Zwerschke, 2011/06/07 + +- Shane Hathaway, 2011/07/22 -- cgit v1.2.3 From acd256b2eb3304834ef0b87f499b1f85dbb014b7 Mon Sep 17 00:00:00 2001 From: Carlos de la Guardia Date: Sat, 23 Jul 2011 00:08:40 -0700 Subject: fix typo --- docs/whatsnew-1.1.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/whatsnew-1.1.rst b/docs/whatsnew-1.1.rst index 6761aaff8..c3161a010 100644 --- a/docs/whatsnew-1.1.rst +++ b/docs/whatsnew-1.1.rst @@ -152,7 +152,7 @@ to only influence ``Cache-Control`` headers, pass a tuple as ``http_cache`` with the first element of ``None``, e.g.: ``(None, {'public':True})``. The environment setting ``PYRAMID_PREVENT_HTTP_CACHE`` and configuration -file value ``prevent_http_cache`` are synomymous and allow you to prevent +file value ``prevent_http_cache`` are synonymous and allow you to prevent HTTP cache headers from being set by Pyramid's ``http_cache`` machinery globally in a process. see :ref:`influencing_http_caching` and :ref:`preventing_http_caching`. -- cgit v1.2.3 From 9f164eeb0ccd77d47e22de5d57739452dfad3cbe Mon Sep 17 00:00:00 2001 From: Carlos de la Guardia Date: Sat, 23 Jul 2011 00:41:03 -0700 Subject: removed extra word --- docs/whatsnew-1.1.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/whatsnew-1.1.rst b/docs/whatsnew-1.1.rst index c3161a010..2a637136f 100644 --- a/docs/whatsnew-1.1.rst +++ b/docs/whatsnew-1.1.rst @@ -479,7 +479,7 @@ Deprecations and Behavior Differences these methods will be removed entirely. - A custom request factory is now required to return a request object that - has a ``response`` attribute (or "reified"/lazy property) if they the + has a ``response`` attribute (or "reified"/lazy property) if the request is meant to be used in a view that uses a renderer. This ``response`` attribute should be an instance of the class :class:`pyramid.response.Response`. -- cgit v1.2.3 From a37a8e4ec1c5b78387b8e93683792c74e8aedcca Mon Sep 17 00:00:00 2001 From: Carlos de la Guardia Date: Sat, 23 Jul 2011 01:01:34 -0700 Subject: Removed extra word, corrected unfinished sentence --- docs/whatsnew-1.1.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/whatsnew-1.1.rst b/docs/whatsnew-1.1.rst index 2a637136f..300b58dbf 100644 --- a/docs/whatsnew-1.1.rst +++ b/docs/whatsnew-1.1.rst @@ -542,8 +542,8 @@ Deprecations and Behavior Differences - Deprecated the :meth:`pyramid.config.Configurator.set_renderer_globals_factory` method and the ``renderer_globals`` Configurator constructor parameter. Users should - use convert code using this feature to use a BeforeRender event als - :ref:`beforerender_event`. + convert code using this feature to use a BeforeRender event. See the section + :ref:`beforerender_event` in the Hooks chapter. - In Pyramid 1.0, the :class:`pyramid.events.subscriber` directive behaved contrary to the documentation when passed more than one interface object to -- cgit v1.2.3 From a03b793abe9a9b5719593716c0191cdc0e9b741b Mon Sep 17 00:00:00 2001 From: Carlos de la Guardia Date: Sat, 23 Jul 2011 01:06:31 -0700 Subject: Fixed typo --- docs/whatsnew-1.1.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/whatsnew-1.1.rst b/docs/whatsnew-1.1.rst index 300b58dbf..18d0aa0b1 100644 --- a/docs/whatsnew-1.1.rst +++ b/docs/whatsnew-1.1.rst @@ -586,7 +586,7 @@ Deprecations and Behavior Differences - The :meth:`pyramid.config.Configurator.add_route` method allowed two routes with the same route to be added without an intermediate call to - :meth:`pyramid.config.Configurator.commit``. If you now receive a + :meth:`pyramid.config.Configurator.commit`. If you now receive a ``ConfigurationError`` at startup time that appears to be ``add_route`` related, you'll need to either a) ensure that all of your route names are unique or b) call ``config.commit()`` before adding a second route with the -- cgit v1.2.3 From b202997e2e0b9eed860afc9baa9497ba5b986fb1 Mon Sep 17 00:00:00 2001 From: Carlos de la Guardia Date: Sat, 23 Jul 2011 01:12:03 -0700 Subject: remove extra word --- docs/narr/introduction.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/narr/introduction.rst b/docs/narr/introduction.rst index 6cc5a87e5..63c31d340 100644 --- a/docs/narr/introduction.rst +++ b/docs/narr/introduction.rst @@ -30,7 +30,7 @@ create web applications. own via a set of libraries if the framework provides a set of facilities that fits your application requirements. -Pyramid attempts to follow follow these design and engineering principles: +Pyramid attempts to follow these design and engineering principles: Simplicity :app:`Pyramid` takes a *"pay only for what you eat"* approach. You can get -- cgit v1.2.3 From 9a66aa09a8a773f67da59642a6642f1a3240c254 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Sat, 23 Jul 2011 13:40:24 -0400 Subject: - The ``pyramid.events.BeforeRender`` event now has an attribute named ``rendering_val``. This can be used to introspect the value returned by a view in a BeforeRender subscriber. --- CHANGES.txt | 10 ++++++++++ pyramid/events.py | 12 +++++++++--- pyramid/interfaces.py | 4 ++++ pyramid/renderers.py | 2 +- pyramid/tests/test_events.py | 9 +++++++-- 5 files changed, 31 insertions(+), 6 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index a2ad1f720..57ab76e46 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,13 @@ +Next release +============ + +Features +-------- + +- The ``pyramid.events.BeforeRender`` event now has an attribute named + ``rendering_val``. This can be used to introspect the value returned by a + view in a BeforeRender subscriber. + 1.1 (2011-07-22) ================ diff --git a/pyramid/events.py b/pyramid/events.py index b536bfd67..4021b94cc 100644 --- a/pyramid/events.py +++ b/pyramid/events.py @@ -193,10 +193,16 @@ class BeforeRender(dict): BeforeRender subscriber, your subscriber code will need to (using ``.get`` or ``__contains__`` of the event object) ensure no value already exists in the renderer globals dictionary before setting an overriding - value.""" + value. - def __init__(self, system): + The event has an additional attribute named ``rendering_val``. This is + the (non-system) value returned by a view or passed to ``render*`` as + ``value``. This feature is new in Pyramid 1.1.1. + """ + + def __init__(self, system, rendering_val=None): self._system = system + self.rendering_val = rendering_val def __setitem__(self, name, value): """ Set a name/value pair into the dictionary which is passed to a @@ -230,4 +236,4 @@ class BeforeRender(dict): """ Return the value for key ``k`` from the renderer globals dictionary, or the default if no such value exists.""" return self._system.get(k) - + diff --git a/pyramid/interfaces.py b/pyramid/interfaces.py index d3a67e1aa..ec1d23acf 100644 --- a/pyramid/interfaces.py +++ b/pyramid/interfaces.py @@ -309,6 +309,10 @@ class IBeforeRender(Interface): """ Return the value for key ``k`` from the renderer globals dictionary, or the default if no such value exists.""" + rendering_val = Attribute('The value returned by a view or passed to a ' + '``render`` method for this rendering. ' + 'This feature is new in Pyramid 1.1.1.') + class IRenderer(Interface): def __call__(value, system): """ Call a the renderer implementation with the result of the diff --git a/pyramid/renderers.py b/pyramid/renderers.py index 52459ee90..c718cf1bb 100644 --- a/pyramid/renderers.py +++ b/pyramid/renderers.py @@ -409,7 +409,7 @@ class RendererHelper(object): if renderer_globals: system_values.update(renderer_globals) - registry.notify(BeforeRender(system_values)) + registry.notify(BeforeRender(system_values, value)) result = renderer(value, system_values) return result diff --git a/pyramid/tests/test_events.py b/pyramid/tests/test_events.py index e3a10ccad..116a48bb7 100644 --- a/pyramid/tests/test_events.py +++ b/pyramid/tests/test_events.py @@ -179,9 +179,9 @@ class TestSubscriber(unittest.TestCase): [(foo, dec.register, 'pyramid')]) class TestBeforeRender(unittest.TestCase): - def _makeOne(self, system): + def _makeOne(self, system, val=None): from pyramid.events import BeforeRender - return BeforeRender(system) + return BeforeRender(system, val) def test_instance_conforms(self): from zope.interface.verify import verifyObject @@ -246,6 +246,11 @@ class TestBeforeRender(unittest.TestCase): event = self._makeOne(system) self.assertEqual(event.get('a'), None) + def test_rendering_val(self): + system = {} + val = {} + event = self._makeOne(system, val) + self.assertTrue(event.rendering_val is val) class DummyConfigurator(object): def __init__(self): -- cgit v1.2.3