Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

- The ``renderer_globals_factory`` argument to the

  ``pyramid.config.Configurator` constructor and its ``setup_registry`` method
  has been removed.  The ``set_renderer_globals_factory`` method of
  ``pyramid.config.Configurator`` has also been removed.  The (internal)
  ``pyramid.interfaces.IRendererGlobals`` interface was also removed.  These
  arguments, methods and interfaces had been deprecated since 1.1.  Use a
  ``BeforeRender`` event subscriber as documented in the "Hooks" chapter of the
  Pyramid narrative documentation instead of providing renderer globals values
  to the configurator.
  • Loading branch information...
commit c6601f77f91dc933ca429d1448f4c6b27857b608 1 parent 95e9711
Chris McDonough mcdonc authored
10 CHANGES.txt
View
@@ -102,6 +102,16 @@ Backwards Incompatibilities
``pyramid.traversal.DefaultRootFactory`` which populated the ``__dict__`` of
the factory with the matchdict values for compatibility with BFG 0.9.
+- The ``renderer_globals_factory`` argument to the
+ ``pyramid.config.Configurator` constructor and its ``setup_registry`` method
+ has been removed. The ``set_renderer_globals_factory`` method of
+ ``pyramid.config.Configurator`` has also been removed. The (internal)
+ ``pyramid.interfaces.IRendererGlobals`` interface was also removed. These
+ arguments, methods and interfaces had been deprecated since 1.1. Use a
+ ``BeforeRender`` event subscriber as documented in the "Hooks" chapter of the
+ Pyramid narrative documentation instead of providing renderer globals values
+ to the configurator.
+
1.5a1 (2013-08-30)
==================
4 docs/api/config.rst
View
@@ -52,10 +52,6 @@
.. automethod:: override_asset(to_override, override_with)
- :methodcategory:`Setting Renderer Globals`
-
- .. automethod:: set_renderer_globals_factory(factory)
-
:methodcategory:`Getting and Adding Settings`
.. automethod:: add_settings
7 docs/glossary.rst
View
@@ -798,9 +798,8 @@ Glossary
:term:`Internationalization`.
renderer globals
- Values injected as names into a renderer based on application
- policy. See :ref:`adding_renderer_globals` for more
- information.
+ Values injected as names into a renderer by a
+ :class:`pyramid.event.BeforeRender` event.
response callback
A user-defined callback executed by the :term:`router` at a
@@ -1021,4 +1020,4 @@ Glossary
add-on
A Python :term:`distribution` that uses Pyramid's extensibility
to plug into a Pyramid application and provide extra,
- configurable services.
+ configurable services.
1  docs/narr/advconfig.rst
View
@@ -302,7 +302,6 @@ These are the methods of the configurator which provide conflict detection:
:meth:`~pyramid.config.Configurator.set_view_mapper`,
:meth:`~pyramid.config.Configurator.set_authentication_policy`,
:meth:`~pyramid.config.Configurator.set_authorization_policy`,
-:meth:`~pyramid.config.Configurator.set_renderer_globals_factory`,
:meth:`~pyramid.config.Configurator.set_locale_negotiator`,
:meth:`~pyramid.config.Configurator.set_default_permission`,
:meth:`~pyramid.config.Configurator.add_traverser`,
66 docs/narr/hooks.rst
View
@@ -372,10 +372,8 @@ that can be used for this purpose. For example:
def add_global(event):
event['mykey'] = 'foo'
-An object of this type is sent as an event just before a :term:`renderer` is
-invoked (but *after* the application-level renderer globals factory added via
-:class:`~pyramid.config.Configurator.set_renderer_globals_factory`, if any,
-has injected its own keys into the renderer globals dictionary).
+An object of this type is sent as an event just before a :term:`renderer`
+is invoked.
If a subscriber attempts to add a key that already exist in the renderer
globals dictionary, a :exc:`KeyError` is raised. This limitation is enforced
@@ -417,66 +415,6 @@ your view callable, like so:
See the API documentation for the :class:`~pyramid.events.BeforeRender` event
interface at :class:`pyramid.interfaces.IBeforeRender`.
-Another (deprecated) mechanism which allows event subscribers more control
-when adding renderer global values exists in :ref:`adding_renderer_globals`.
-
-.. index::
- single: adding renderer globals
-
-.. _adding_renderer_globals:
-
-Adding Renderer Globals (Deprecated)
-------------------------------------
-
-.. deprecated:: 1.1
- An alternative mechanism which allows event subscribers to add renderer
- global values is documented in :ref:`beforerender_event`.
-
-Whenever :app:`Pyramid` handles a request to perform a rendering (after a
-view with a ``renderer=`` configuration attribute is invoked, or when any of
-the methods beginning with ``render`` within the :mod:`pyramid.renderers`
-module are called), *renderer globals* can be injected into the *system*
-values sent to the renderer. By default, no renderer globals are injected,
-and the "bare" system values (such as ``request``, ``context``, ``view``, and
-``renderer_name``) are the only values present in the system dictionary
-passed to every renderer.
-
-A callback that :app:`Pyramid` will call every time a renderer is invoked can
-be added by passing a ``renderer_globals_factory`` argument to the
-constructor of the :term:`configurator`. This callback can either be a
-callable object or a :term:`dotted Python name` representing such a callable.
-
-.. code-block:: python
- :linenos:
-
- def renderer_globals_factory(system):
- return {'a': 1}
-
- config = Configurator(
- renderer_globals_factory=renderer_globals_factory)
-
-Such a callback must accept a single positional argument (notionally named
-``system``) which will contain the original system values. It must return a
-dictionary of values that will be merged into the system dictionary. See
-:ref:`renderer_system_values` for description of the values present in the
-system dictionary.
-
-If you're doing imperative configuration, and you'd rather do it after you've
-already constructed a :term:`configurator` it can also be registered via the
-:meth:`pyramid.config.Configurator.set_renderer_globals_factory` method:
-
-.. code-block:: python
- :linenos:
-
- from pyramid.config import Configurator
-
- def renderer_globals_factory(system):
- return {'a': 1}
-
- config = Configurator()
- config.set_renderer_globals_factory(renderer_globals_factory)
-
-
.. index::
single: response callback
12 docs/narr/introspector.rst
View
@@ -232,18 +232,6 @@ introspectables in categories not described here.
The factory object (the resolved ``factory`` argument to
``add_renderer``).
-``renderer globals factory``
-
- There will be one and only one introspectable in the ``renderer globals
- factory`` category. It represents a call to
- :meth:`pyramid.config.Configurator.set_renderer_globals_factory`; it will
- have the following data.
-
- ``factory``
-
- The factory object (the resolved ``factory`` argument to
- ``set_renderer_globals_factory``).
-
``routes``
Each introspectable in the ``routes`` category represents a call to
9 docs/whatsnew-1.1.rst
View
@@ -540,11 +540,10 @@ Deprecations and Behavior Differences
within a static view returns the index.html properly. See also
https://github.com/Pylons/pyramid/issues/67.
-- Deprecated the
- :meth:`pyramid.config.Configurator.set_renderer_globals_factory` method and
- the ``renderer_globals`` Configurator constructor parameter. Users should
- convert code using this feature to use a BeforeRender event. See the section
- :ref:`beforerender_event` in the Hooks chapter.
+- Deprecated the ``pyramid.config.Configurator.set_renderer_globals_factory``
+ method and the ``renderer_globals`` Configurator constructor parameter.
+ Users should 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
23 pyramid/config/__init__.py
View
@@ -173,15 +173,6 @@ class Configurator(
See :ref:`changing_the_request_factory`. By default it is ``None``,
which means use the default request factory.
- If ``renderer_globals_factory`` is passed, it should be a :term:`renderer
- globals` factory implementation or a :term:`dotted Python name` to the
- same. See :ref:`adding_renderer_globals`. By default, it is ``None``,
- which means use no renderer globals factory.
-
- .. deprecated:: 1.1
- Use a BeforeRender event subscriber as per :ref:`beforerender_event`
- in place of ``renderer_globals_factory``.
-
If ``default_permission`` is passed, it should be a
:term:`permission` string to be used as the default permission for
all view configuration registrations performed against this
@@ -273,7 +264,6 @@ def __init__(self,
debug_logger=None,
locale_negotiator=None,
request_factory=None,
- renderer_globals_factory=None,
default_permission=None,
session_factory=None,
default_view_mapper=None,
@@ -304,7 +294,6 @@ def __init__(self,
debug_logger=debug_logger,
locale_negotiator=locale_negotiator,
request_factory=request_factory,
- renderer_globals_factory=renderer_globals_factory,
default_permission=default_permission,
session_factory=session_factory,
default_view_mapper=default_view_mapper,
@@ -320,7 +309,6 @@ def setup_registry(self,
debug_logger=None,
locale_negotiator=None,
request_factory=None,
- renderer_globals_factory=None,
default_permission=None,
session_factory=None,
default_view_mapper=None,
@@ -410,17 +398,6 @@ def setup_registry(self,
if request_factory:
self.set_request_factory(request_factory)
- if renderer_globals_factory:
- warnings.warn(
- 'Passing ``renderer_globals_factory`` as a Configurator '
- 'constructor parameter is deprecated as of Pyramid 1.1. '
- 'Use a BeforeRender event subscriber as documented in the '
- '"Hooks" chapter of the Pyramid narrative documentation '
- 'instead',
- DeprecationWarning,
- 2)
- self.set_renderer_globals_factory(renderer_globals_factory,
- warn=False)
if default_permission:
self.set_default_permission(default_permission)
44 pyramid/config/rendering.py
View
@@ -1,8 +1,5 @@
-import warnings
-
from pyramid.interfaces import (
IRendererFactory,
- IRendererGlobalsFactory,
PHASE1_CONFIG,
)
@@ -48,44 +45,3 @@ def register():
self.action((IRendererFactory, name), register, order=PHASE1_CONFIG,
introspectables=(intr,))
- @action_method
- def set_renderer_globals_factory(self, factory, warn=True):
- """ The object passed as ``factory`` should be an callable (or
- a :term:`dotted Python name` which refers to an callable) that
- will be used by the :app:`Pyramid` rendering machinery as a
- renderers global factory (see :ref:`adding_renderer_globals`).
-
- The ``factory`` callable must accept a single argument named
- ``system`` (which will be a dictionary) and it must return a
- dictionary. When an application uses a renderer, the
- factory's return dictionary will be merged into the ``system``
- dictionary, and therefore will be made available to the code
- which uses the renderer.
-
- .. deprecated:: 1.1
- Use a BeforeRender event subscriber as documented in the
- :ref:`hooks_chapter` chapter instead.
-
- .. note::
-
- Using the ``renderer_globals_factory`` argument
- to the :class:`pyramid.config.Configurator` constructor
- can be used to achieve the same purpose.
- """
- if warn:
- warnings.warn(
- 'Calling the ``set_renderer_globals`` method of a Configurator '
- 'is deprecated as of Pyramid 1.1. Use a BeforeRender event '
- 'subscriber as documented in the "Hooks" chapter of the '
- 'Pyramid narrative documentation instead',
- DeprecationWarning,
- 3)
-
- factory = self.maybe_dotted(factory)
- def register():
- self.registry.registerUtility(factory, IRendererGlobalsFactory)
- intr = self.introspectable('renderer globals factory', None,
- self.object_description(factory),
- 'renderer globals factory')
- intr['factory'] = factory
- self.action(IRendererGlobalsFactory, register)
5 pyramid/events.py
View
@@ -192,10 +192,7 @@ def add_global(event):
event['mykey'] = 'foo'
An object of this type is sent as an event just before a :term:`renderer`
- is invoked (but *after* the -- deprecated -- application-level renderer
- globals factory added via
- :class:`pyramid.config.Configurator.set_renderer_globals_factory`, if
- any, has injected its own keys into the renderer globals dictionary).
+ is invoked.
If a subscriber adds a key via ``__setitem__`` that already exists in
the renderer globals dictionary, it will overwrite the older value there.
9 pyramid/interfaces.py
View
@@ -616,15 +616,6 @@ def __call__(info):
""" Return an object that implements ``IRenderer``. ``info`` is an
object that implement ``IRendererInfo``. """
-class IRendererGlobalsFactory(Interface):
- def __call__(system_values):
- """ Return a dictionary of global renderer values (aka
- top-level template names). The ``system_values`` value passed
- in will be a dictionary that includes at least a ``request``
- key, indicating the current request, and the value
- ``renderer_name``, which will be the name of the renderer in
- use."""
-
class IViewPermission(Interface):
def __call__(context, request):
""" Return True if the permission allows, return False if it denies. """
8 pyramid/renderers.py
View
@@ -9,7 +9,6 @@
from pyramid.interfaces import (
IJSONAdapter,
- IRendererGlobalsFactory,
IRendererFactory,
IResponseFactory,
IRendererInfo,
@@ -425,13 +424,6 @@ def render(self, value, system_values, request=None):
system_values = BeforeRender(system_values, value)
registry = self.registry
- globals_factory = registry.queryUtility(IRendererGlobalsFactory)
-
- if globals_factory is not None:
- renderer_globals = globals_factory(system_values)
- if renderer_globals:
- system_values.update(renderer_globals)
-
registry.notify(system_values)
result = renderer(value, system_values)
29 pyramid/tests/test_config/test_init.py
View
@@ -550,35 +550,6 @@ def test_setup_registry_request_factory_dottedname(self):
utility = reg.getUtility(IRequestFactory)
self.assertEqual(utility, pyramid.tests.test_config)
- def test_setup_registry_renderer_globals_factory(self):
- from pyramid.registry import Registry
- from pyramid.interfaces import IRendererGlobalsFactory
- reg = Registry()
- config = self._makeOne(reg)
- factory = object()
- with warnings.catch_warnings():
- warnings.filterwarnings('ignore')
- config.setup_registry(renderer_globals_factory=factory)
- self.assertEqual(reg.queryUtility(IRendererGlobalsFactory), None)
- config.commit()
- utility = reg.getUtility(IRendererGlobalsFactory)
- self.assertEqual(utility, factory)
-
- def test_setup_registry_renderer_globals_factory_dottedname(self):
- from pyramid.registry import Registry
- from pyramid.interfaces import IRendererGlobalsFactory
- reg = Registry()
- config = self._makeOne(reg)
- import pyramid.tests.test_config
- with warnings.catch_warnings():
- warnings.filterwarnings('ignore')
- config.setup_registry(
- renderer_globals_factory='pyramid.tests.test_config')
- self.assertEqual(reg.queryUtility(IRendererGlobalsFactory), None)
- config.commit()
- utility = reg.getUtility(IRendererGlobalsFactory)
- self.assertEqual(utility, pyramid.tests.test_config)
-
def test_setup_registry_alternate_renderers(self):
from pyramid.registry import Registry
from pyramid.interfaces import IRendererFactory
25 pyramid/tests/test_config/test_rendering.py
View
@@ -1,7 +1,4 @@
import unittest
-import warnings
-
-from pyramid.tests.test_config import dummyfactory
class TestRenderingConfiguratorMixin(unittest.TestCase):
def _makeOne(self, *arg, **kw):
@@ -9,28 +6,6 @@ def _makeOne(self, *arg, **kw):
config = Configurator(*arg, **kw)
return config
- def test_set_renderer_globals_factory(self):
- from pyramid.interfaces import IRendererGlobalsFactory
- config = self._makeOne(autocommit=True)
- factory = object()
- with warnings.catch_warnings():
- warnings.filterwarnings('ignore')
- config.set_renderer_globals_factory(factory)
- self.assertEqual(
- config.registry.getUtility(IRendererGlobalsFactory),
- factory)
-
- def test_set_renderer_globals_factory_dottedname(self):
- from pyramid.interfaces import IRendererGlobalsFactory
- config = self._makeOne(autocommit=True)
- with warnings.catch_warnings():
- warnings.filterwarnings('ignore')
- config.set_renderer_globals_factory(
- 'pyramid.tests.test_config.dummyfactory')
- self.assertEqual(
- config.registry.getUtility(IRendererGlobalsFactory),
- dummyfactory)
-
def test_add_renderer(self):
from pyramid.interfaces import IRendererFactory
config = self._makeOne(autocommit=True)
10 pyramid/tests/test_renderers.py
View
@@ -255,16 +255,6 @@ def test_render_system_values_is_None(self):
self.assertEqual(result[0], 'values')
self.assertEqual(result[1], system)
- def test_render_renderer_globals_factory_active(self):
- self._registerRendererFactory()
- from pyramid.interfaces import IRendererGlobalsFactory
- def rg(system):
- return {'a':1}
- self.config.registry.registerUtility(rg, IRendererGlobalsFactory)
- helper = self._makeOne('loo.foo')
- result = helper.render('values', None)
- self.assertEqual(result[1]['a'], 1)
-
def test__make_response_request_is_None(self):
request = None
helper = self._makeOne('loo.foo')
Please sign in to comment.
Something went wrong with that request. Please try again.