diff options
| author | Chris McDonough <chrism@agendaless.com> | 2009-09-30 05:23:02 +0000 |
|---|---|---|
| committer | Chris McDonough <chrism@agendaless.com> | 2009-09-30 05:23:02 +0000 |
| commit | 27ae86b27d2ea8956210a12c7564e07b3f6101ff (patch) | |
| tree | e9fc9d94ec8dc12379ea198cedce2ed35c455edd | |
| parent | 58409e344560d87b3504ca86a5fb3f5c4a3bc3da (diff) | |
| download | pyramid-27ae86b27d2ea8956210a12c7564e07b3f6101ff.tar.gz pyramid-27ae86b27d2ea8956210a12c7564e07b3f6101ff.tar.bz2 pyramid-27ae86b27d2ea8956210a12c7564e07b3f6101ff.zip | |
- Describe "request-only" view calling conventions inside the
urldispatch narrative chapter, where it's most helpful.
| -rw-r--r-- | CHANGES.txt | 3 | ||||
| -rw-r--r-- | docs/narr/urldispatch.rst | 23 | ||||
| -rw-r--r-- | docs/narr/views.rst | 2 |
3 files changed, 28 insertions, 0 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index 8a82bc086..9ead6e65e 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -10,6 +10,9 @@ Documentation - An ``exceptions`` API chapter was added, documenting the new ``repoze.bfg.exceptions`` module. +- Describe "request-only" view calling conventions inside the + urldispatch narrative chapter, where it's most helpful. + Features -------- diff --git a/docs/narr/urldispatch.rst b/docs/narr/urldispatch.rst index a8d50f9e2..a43d5e125 100644 --- a/docs/narr/urldispatch.rst +++ b/docs/narr/urldispatch.rst @@ -349,6 +349,29 @@ type of object created for a context when there is no "factory" specified in the ``route`` declaration. It is a mapping object, a lot like a dictionary. +When using :term:`url dispatch` exclusively in an application (as +opposed to using both url dispatch and :term:`traversal`), the +*context* of the view isn't terribly interesting most of the time, +particularly if you never use a ``factory`` attribute on your route +definitions. For this reason, :mod:`repoze.bfg` supports view +callables defined with only a ``request`` argument in their argument +specification. For example, the below view statement is competely +equivalent to the above view statement: + +.. code-block:: python + :linenos: + + from webob import Response + + def hello_view(request): + return Response('Hello!') + +Even if you use the request-only argument format in view callables, +you can still get to the ``context`` of the view (if necessary) by +accessing ``request.context``. + +See also: :ref:`request_only_view_definitions`. + Example 2 ~~~~~~~~~ diff --git a/docs/narr/views.rst b/docs/narr/views.rst index b45221e71..53fedbedc 100644 --- a/docs/narr/views.rst +++ b/docs/narr/views.rst @@ -82,6 +82,8 @@ represent the method expected to return a response, you can use an ``attr`` value as part of view configuration. See :ref:`view_configuration`. +.. _request_only_view_definitions: + Request-Only View Definitions ----------------------------- |
