diff options
| author | Chris McDonough <chrism@plope.com> | 2010-12-09 02:50:15 -0500 |
|---|---|---|
| committer | Chris McDonough <chrism@plope.com> | 2010-12-09 02:50:15 -0500 |
| commit | f360d9e6d9689dfe92a950e97e7e19c414655997 (patch) | |
| tree | f0456af418ecfaf7d5a342556d2c5786b2aee979 /docs/narr/handlers.rst | |
| parent | c18b16d293ee60117747f0de042e2d75361d1fd8 (diff) | |
| parent | 13173e9e1d1c5f3873e8bfed91e6f3ed561dafaf (diff) | |
| download | pyramid-f360d9e6d9689dfe92a950e97e7e19c414655997.tar.gz pyramid-f360d9e6d9689dfe92a950e97e7e19c414655997.tar.bz2 pyramid-f360d9e6d9689dfe92a950e97e7e19c414655997.zip | |
Merge branch 'twophase'
Conflicts:
pyramid/configuration.py
Diffstat (limited to 'docs/narr/handlers.rst')
| -rw-r--r-- | docs/narr/handlers.rst | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/docs/narr/handlers.rst b/docs/narr/handlers.rst index 0dce6afe4..49dd73f7f 100644 --- a/docs/narr/handlers.rst +++ b/docs/narr/handlers.rst @@ -6,8 +6,8 @@ View Handlers Along with normal view callables, :app:`Pyramid` provides the concept of a :term:`view handler`. Using a view handler instead of a plain :term:`view callable` makes it unnecessary to call -:meth:`pyramid.configuration.Configurator.add_route` (and/or -:meth:`pyramid.configuration.Configurator.add_view`) "by hand" multiple +:meth:`pyramid.config.Configurator.add_route` (and/or +:meth:`pyramid.config.Configurator.add_view`) "by hand" multiple times, making it more pleasant to register a collection of views as a single class when using :term:`url dispatch`. The view handler machinery also introduces the concept of an ``action``, which is used as a :term:`view @@ -26,7 +26,7 @@ a view handler registration made during configuration. A method of the view handler class is then called. The method which is called depends on the view handler configuration. -The :meth:`pyramid.configuration.Configurator.add_handler` method will scan +The :meth:`pyramid.config.Configurator.add_handler` method will scan the handler class and automatically set up views for methods that are auto-exposed or were decorated with :class:`~pyramid.view.action`. The :class:`~pyramid.view.action` decorator is used to setup additional view @@ -55,7 +55,7 @@ Here's an example view handler class: return {} An accompanying call to the -:meth:`~pyramid.configuration.Configurator.add_handler` for the handler must +:meth:`~pyramid.config.Configurator.add_handler` for the handler must be performed in order to register it with the system: .. code-block:: python @@ -87,15 +87,15 @@ handler class not named 'index' might be called if they were configured to be called when the ``action`` name is 'index' as will be seen below. -Using :meth:`~pyramid.configuration.Configurator.add_handler` +Using :meth:`~pyramid.config.Configurator.add_handler` ------------------------------------------------------------- -When calling :meth:`~pyramid.configuration.Configurator.add_handler`, an +When calling :meth:`~pyramid.config.Configurator.add_handler`, an ``action`` is required in either the route pattern or as a keyword argument, but **cannot appear in both places**. A ``handler`` argument must also be supplied, which can be either a :term:`resource specification` or a Python reference to the handler class. Additional keyword arguments are passed -directly through to :meth:`pyramid.configuration.Configurator.add_route`. +directly through to :meth:`pyramid.config.Configurator.add_route`. For example: @@ -106,10 +106,10 @@ For example: handler='mypackage.handlers:MyHandler') In larger applications, it is advised to use a :term:`resource specification` -with :meth:`~pyramid.configuration.Configurator.add_handler` to avoid having +with :meth:`~pyramid.config.Configurator.add_handler` to avoid having to import every handler class. -Multiple :meth:`~pyramid.configuration.Configurator.add_handler` calls can +Multiple :meth:`~pyramid.config.Configurator.add_handler` calls can specify the same handler, to register specific route names for different handler/action combinations. For example: @@ -130,7 +130,7 @@ The handler class specified can have a single class level attribute called ``None``. It's used to determine which method names will result in additional view configurations being registered. -When :meth:`~pyramid.configuration.Configurator.add_handler` runs, every +When :meth:`~pyramid.config.Configurator.add_handler` runs, every method in the handler class will be searched and a view registered if the method name matches the ``__autoexpose__`` regular expression, or if the method was decorated with :class:`~pyramid.view.action`. @@ -170,12 +170,12 @@ Action Decorator The :class:`~pyramid.view.action` decorator registers view configuration information on the handler method which is used by -:meth:`~pyramid.configuration.Configurator.add_handler` to setup the view +:meth:`~pyramid.config.Configurator.add_handler` to setup the view configuration. All keyword arguments are recorded, and passed to -:meth:`~pyramid.configuration.Configurator.add_view`. Any valid keyword -arguments for :meth:`~pyramid.configuration.Configurator.add_view` can thus be +:meth:`~pyramid.config.Configurator.add_view`. Any valid keyword +arguments for :meth:`~pyramid.config.Configurator.add_view` can thus be used with the :class:`~pyramid.view.action` decorator to further restrict when the view will be called. |
