diff options
| author | Chris McDonough <chrism@plope.com> | 2010-10-31 03:01:18 -0400 |
|---|---|---|
| committer | Chris McDonough <chrism@plope.com> | 2010-10-31 03:01:18 -0400 |
| commit | 3d9dd0e9c1e88c2260de2fee1db8108d44867a8f (patch) | |
| tree | b0dc32b89a8bbfd64915240b37bfac572807fbe3 /docs/narr | |
| parent | 051e27a386e9a774b3b1e8c705aa0c8de8e129c3 (diff) | |
| download | pyramid-3d9dd0e9c1e88c2260de2fee1db8108d44867a8f.tar.gz pyramid-3d9dd0e9c1e88c2260de2fee1db8108d44867a8f.tar.bz2 pyramid-3d9dd0e9c1e88c2260de2fee1db8108d44867a8f.zip | |
- Renderer factories now accept a *dictionary* rather than an absolute resource
specification or an absolute path. The dictonary contains the following
keys: ``name`` (the ``renderer=`` value), ``package`` (the 'current package'
when the renderer configuration statement was found), ``type``: the renderer
type, and ``registry``: the current registry.
Third-party ``repoze.bfg`` renderer implementations that must be ported to
Pyramid will need to account for this.
This change was made to support more flexible Mako template rendering.
Diffstat (limited to 'docs/narr')
| -rw-r--r-- | docs/narr/environment.rst | 2 | ||||
| -rw-r--r-- | docs/narr/views.rst | 54 |
2 files changed, 28 insertions, 28 deletions
diff --git a/docs/narr/environment.rst b/docs/narr/environment.rst index fa639cce1..83de12863 100644 --- a/docs/narr/environment.rst +++ b/docs/narr/environment.rst @@ -195,7 +195,7 @@ should be changed accordingly. +-----------------------------+ | Config File Setting Name | +=============================+ -| ``mako.input_encoding``__ | +| ``mako.input_encoding`` | | | | | | | diff --git a/docs/narr/views.rst b/docs/narr/views.rst index c74263bdc..0070e7a73 100644 --- a/docs/narr/views.rst +++ b/docs/narr/views.rst @@ -738,9 +738,12 @@ following interface: :linenos: class RendererFactory: - def __init__(self, name): - """ Constructor: ``name`` may be an absolute path or a - resource specification """ + def __init__(self, info): + """ Constructor: ``info`` will be a dictionary containing the + following keys: ``name`` (the renderer name), ``package``: the + package that was 'current' at the time the renderer was registered, + ``type``: the renderer type name, and ``registry``: the current + registry. """ def __call__(self, value, system): """ Call a the renderer implementation with the value and @@ -752,18 +755,17 @@ following interface: There are essentially two different kinds of renderer factories: -- A renderer factory which expects to accept a :term:`resource - specification` or an absolute path as the ``name`` value in its - constructor. These renderer factories are registered with a - ``name`` value that begins with a dot (``.``). These types of - renderer factories usually relate to a file on the filesystem, such - as a template. +- A renderer factory which expects to accept a :term:`resource specification` + or an absolute path as the ``name`` value in the ``info`` value fed to its + constructor. These renderer factories are registered with a ``name`` value + that begins with a dot (``.``). These types of renderer factories usually + relate to a file on the filesystem, such as a template. -- A renderer factory which expects to accept a token that does not - represent a filesystem path or a resource specification in its - constructor. These renderer factories are registered with a - ``name`` value that does not begin with a dot. These renderer - factories are typically object serializers. +- A renderer factory which expects to accept a token that does not represent a + filesystem path or a resource specification in the ``name`` value of the + ``info`` dict fed to its constructor. These renderer factories are + registered with a ``name`` value that does not begin with a dot. These + renderer factories are typically object serializers. .. sidebar:: Resource Specifications @@ -832,19 +834,17 @@ configuration`: def myview(request): return {'Hello':'world'} -When a :term:`view configuration` which has a ``name`` attribute that -does contain a dot, such as ``templates/mytemplate.jinja2`` above is -encountered at startup time, the value of the name attribute is split -on its final dot. The second element of the split is typically the -filename extension. This extension is used to look up a renderer -factory for the configured view. Then the value of ``renderer`` is -passed to the factory to create a renderer for the view. In this -case, the view configuration will create an instance of a -``Jinja2Renderer`` for each view configuration which includes anything -ending with ``.jinja2`` as its ``renderer`` value. The ``name`` -passed to the ``Jinja2Renderer`` constructor will usually be a -:term:`resource specification`, but may also be an absolute path; the -renderer factory implementation should be able to deal with either. +When a :term:`view configuration` which has a ``name`` attribute that does +contain a dot, such as ``templates/mytemplate.jinja2`` above is encountered at +startup time, the value of the name attribute is split on its final dot. The +second element of the split is typically the filename extension. This +extension is used to look up a renderer factory for the configured view. Then +the value of ``renderer`` is passed to the factory to create a renderer for the +view. In this case, the view configuration will create an instance of a +``Jinja2Renderer`` for each view configuration which includes anything ending +with ``.jinja2`` as its ``renderer`` value. The ``name`` passed to the +``Jinja2Renderer`` constructor will be whatever the user passed as +``renderer=`` to the view configuration. See also :ref:`renderer_directive` and :meth:`pyramid.configuration.Configurator.add_renderer`. |
