diff options
| author | Casey Duncan <casey.duncan@gmail.com> | 2010-12-12 09:40:19 -0700 |
|---|---|---|
| committer | Casey Duncan <casey.duncan@gmail.com> | 2010-12-12 09:40:19 -0700 |
| commit | 226c469217cbddc3443da2a60dc414b82021bcbe (patch) | |
| tree | c049b1c25b4b70a43f2b99f8515fd3d628cbffd2 /docs/narr/views.rst | |
| parent | 87a6ffdb91ae9f983169c3e9da15ea0266745a74 (diff) | |
| parent | fee38663daccc0130d0c34dbc5a14e67bef2e183 (diff) | |
| download | pyramid-226c469217cbddc3443da2a60dc414b82021bcbe.tar.gz pyramid-226c469217cbddc3443da2a60dc414b82021bcbe.tar.bz2 pyramid-226c469217cbddc3443da2a60dc414b82021bcbe.zip | |
fix merge conflicts
Diffstat (limited to 'docs/narr/views.rst')
| -rw-r--r-- | docs/narr/views.rst | 51 |
1 files changed, 30 insertions, 21 deletions
diff --git a/docs/narr/views.rst b/docs/narr/views.rst index d30fcdae5..8a689be21 100644 --- a/docs/narr/views.rst +++ b/docs/narr/views.rst @@ -338,7 +338,7 @@ within :ref:`the_response`. View configuration can vary the renderer associated with a view callable via the ``renderer`` attribute. For example, this call to -:meth:`pyramid.configuration.Configurator.add_view` associates the ``json`` +:meth:`pyramid.config.Configurator.add_view` associates the ``json`` renderer with a view callable: .. code-block:: python @@ -469,7 +469,7 @@ contain values serializable by :func:`json.dumps`. You can configure a view to use the JSON renderer by naming ``json`` as the ``renderer`` argument of a view configuration, e.g. by using -:meth:`pyramid.configuration.Configurator.add_view`: +:meth:`pyramid.config.Configurator.add_view`: .. code-block:: python :linenos: @@ -537,7 +537,7 @@ renderer: .. code-block:: python :linenos: - # config is an instance of pyramid.configuration.Configurator + # config is an instance of pyramid.config.Configurator config.add_view('myproject.views.hello_world', name='hello', @@ -588,7 +588,7 @@ Here's an example view configuration which uses a relative path: .. code-block:: python :linenos: - # config is an instance of pyramid.configuration.Configurator + # config is an instance of pyramid.config.Configurator config.add_view('myproject.views.hello_world', name='hello', @@ -689,7 +689,7 @@ override an existing :term:`renderer factory`, and which add a new renderer factory. Renderers can be registered imperatively using the -:meth:`pyramid.configuration.Configurator.add_renderer` API. +:meth:`pyramid.config.Configurator.add_renderer` API. .. note:: The tasks described in this section can also be performed via :term:`declarative configuration`. See @@ -768,12 +768,12 @@ There are essentially two different kinds of renderer factories: ``my.package`` Python :term:`package`. Here's an example of the registration of a simple renderer factory via -:meth:`pyramid.configuration.Configurator.add_renderer`: +:meth:`pyramid.config.Configurator.add_renderer`: .. code-block:: python :linenos: - # config is an instance of pyramid.configuration.Configurator + # config is an instance of pyramid.config.Configurator config.add_renderer(name='amf', factory='my.package.MyAMFRenderer') @@ -836,7 +836,7 @@ to the ``Jinja2Renderer`` constructor will be the full value that was set as ``renderer=`` in the view configuration. See also :ref:`renderer_directive` and -:meth:`pyramid.configuration.Configurator.add_renderer`. +:meth:`pyramid.config.Configurator.add_renderer`. Overriding an Existing Renderer +++++++++++++++++++++++++++++++ @@ -845,7 +845,7 @@ You can associate more than one filename extension with the same existing renderer implementation as necessary if you need to use a different file extension for the same kinds of templates. For example, to associate the ``.zpt`` extension with the Chameleon ZPT renderer factory, use the -:meth:`pyramid.configuration.Configurator.add_renderer` method: +:meth:`pyramid.config.Configurator.add_renderer` method: .. code-block:: python :linenos: @@ -1145,8 +1145,8 @@ View configuration is performed in one of these ways: object as per :class:`pyramid.view.view_config` and :ref:`mapping_views_using_a_decorator_section`. -- by using the :meth:`pyramid.configuration.Configurator.add_view` - method as per :meth:`pyramid.configuration.Configurator.add_view` +- by using the :meth:`pyramid.config.Configurator.add_view` + method as per :meth:`pyramid.config.Configurator.add_view` and :ref:`mapping_views_using_imperative_config_section`. Both of these mechanisms is completely equivalent to the other. @@ -1157,7 +1157,7 @@ Both of these mechanisms is completely equivalent to the other. A view configuration might also be performed by virtue of :term:`route configuration`. View configuration via route configuration is performed by -using the :meth:`pyramid.configuration.Configurator.add_route` method to +using the :meth:`pyramid.config.Configurator.add_route` method to create a route with a ``view`` argument. .. note:: ZCML users can use :ref:`route_directive` to perform the same task. @@ -1458,7 +1458,7 @@ configuration`, like ZCML, but in decorator form. :class:`pyramid.view.view_config` can be used to associate :term:`view configuration` information -- as done via the equivalent imperative code or ZCML -- with a function that acts as a :app:`Pyramid` view callable. All -arguments to the :meth:`pyramid.configuration.Configurator.add_view` method +arguments to the :meth:`pyramid.config.Configurator.add_view` method (save for the ``view`` argument) are available in decorator form and mean precisely the same thing. @@ -1512,13 +1512,13 @@ perform view configuration. All that the decorator does is "annotate" the function with your configuration declarations, it doesn't process them. To make :app:`Pyramid` process your :class:`pyramid.view.view_config` declarations, you *must* do use the -``scan`` method of a :class:`pyramid.configuration.Configurator`: +``scan`` method of a :class:`pyramid.config.Configurator`: .. code-block:: python :linenos: # config is assumed to be an instance of the - # pyramid.configuration.Configurator class + # pyramid.config.Configurator class config.scan() .. note:: See :ref:`zcml_scanning` for information about how to invoke a scan @@ -1529,7 +1529,7 @@ about what happens when code is scanned for configuration declarations resulting from use of decorators like :class:`pyramid.view.view_config`. See :ref:`configuration_module` for additional API arguments to the -:meth:`pyramid.configuration.Configurator.scan` method. For example, the +:meth:`pyramid.config.Configurator.scan` method. For example, the method allows you to supply a ``package`` argument to better control exactly *which* code will be scanned. @@ -1661,7 +1661,7 @@ equivalently as the below: View Configuration Using the ``add_view`` Method of a Configurator ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The :meth:`pyramid.configuration.Configurator.add_view` method +The :meth:`pyramid.config.Configurator.add_view` method within :ref:`configuration_module` is used to configure a view imperatively. The arguments to this method are very similar to the arguments that you provide to the ``@view_config`` decorator. For @@ -1676,13 +1676,13 @@ example: return Response('hello!') # config is assumed to be an instance of the - # pyramid.configuration.Configurator class + # pyramid.config.Configurator class config.add_view(hello_world, name='hello.html') The first argument, ``view``, is required. It must either be a Python object which is the view itself or a :term:`dotted Python name` to such an object. All other arguments are optional. See -:meth:`pyramid.configuration.Configurator.add_view` for more +:meth:`pyramid.config.Configurator.add_view` for more information. .. index:: @@ -1758,7 +1758,7 @@ this interface. .. code-block:: python :linenos: - # config is an instance of pyramid.configuration.Configurator + # config is an instance of pyramid.config.Configurator config.add_view('mypackage.views.hello_world', name='hello.html', context='mypackage.models.IHello') @@ -1787,6 +1787,7 @@ view configuration, see :ref:`models_which_implement_interfaces`. Configuring View Security ~~~~~~~~~~~~~~~~~~~~~~~~~ +<<<<<<< HEAD If an :term:`authorization policy` is active, any :term:`permission` attached to a :term:`view configuration` found during view lookup will be verified. This will ensure that the currently authenticated user @@ -1794,11 +1795,19 @@ possesses that permission against the :term:`context` before the view function is actually called. Here's an example of specifying a permission in a view configuration using :meth:`pyramid.configuration.Configurator.add_view`: +======= +If a :term:`authorization policy` is active, any :term:`permission` attached +to a :term:`view configuration` found during view lookup will be consulted to +ensure that the currently authenticated user possesses that permission +against the :term:`context` before the view function is actually called. +Here's an example of specifying a permission in a view configuration using +:meth:`pyramid.config.Configurator.add_view`: +>>>>>>> fee38663daccc0130d0c34dbc5a14e67bef2e183 .. code-block:: python :linenos: - # config is an instance of pyramid.configuration.Configurator + # config is an instance of pyramid.config.Configurator config.add_view('myproject.views.add_entry', name='add.html', context='myproject.models.IBlog', permission='add') |
