summaryrefslogtreecommitdiff
path: root/docs/tutorials/wiki2/definingviews.rst
diff options
context:
space:
mode:
Diffstat (limited to 'docs/tutorials/wiki2/definingviews.rst')
-rw-r--r--docs/tutorials/wiki2/definingviews.rst42
1 files changed, 19 insertions, 23 deletions
diff --git a/docs/tutorials/wiki2/definingviews.rst b/docs/tutorials/wiki2/definingviews.rst
index f2ac2f85f..a1e2313f3 100644
--- a/docs/tutorials/wiki2/definingviews.rst
+++ b/docs/tutorials/wiki2/definingviews.rst
@@ -6,16 +6,13 @@ A :term:`view callable` in a :app:`Pyramid` application is typically a simple
Python function that accepts a single parameter named :term:`request`. A
view callable is assumed to return a :term:`response` object.
-The request object passed to every view that is called as the result of a
-route match has an attribute named ``matchdict`` that contains the elements
-placed into the URL by the ``pattern`` of a ``route`` statement. For
-instance, if a call to :meth:`pyramid.config.Configurator.add_route` in
-``__init__.py`` had the pattern ``{one}/{two}``, and the URL at
-``http://example.com/foo/bar`` was invoked, matching this pattern, the
-``matchdict`` dictionary attached to the request passed to the view would
-have a ``'one'`` key with the value ``'foo'`` and a ``'two'`` key with the
-value ``'bar'``.
-
+The request object has a dictionary as an attribute named ``matchdict``. A
+``matchdict`` maps the placeholders in the matching URL ``pattern`` to the
+substrings of the path in the :term:`request` URL. For instance, if a call to
+:meth:`pyramid.config.Configurator.add_route` has the pattern ``/{one}/{two}``,
+and a user visits ``http://example.com/foo/bar``, our pattern would be matched
+against ``/foo/bar`` and the ``matchdict`` would look like: ``{'one':'foo',
+'two':'bar'}``
Declaring Dependencies in Our ``setup.py`` File
===============================================
@@ -148,14 +145,13 @@ As a result, the ``content`` variable is now a fully formed bit of HTML
containing various view and add links for WikiWords based on the content of
our current page object.
-We then generate an edit URL (because it's easier to do here than in the
-template), and we return a dictionary with a number of arguments. The fact
-that ``view_page()`` returns a dictionary (as opposed to a :term:`response`
-object) is a cue to :app:`Pyramid` that it should try to use a :term:`renderer`
-associated with the view configuration to render a template. In our case,
-the template which will be rendered will be the ``templates/view.pt``
-template, as indicated in the ``@view_config`` decorator that is applied to
-``view_page()``.
+We then generate an edit URL because it's easier to do here than in the
+template, and we return a dictionary with a number of arguments. The fact that
+``view_page()`` returns a dictionary (as opposed to a :term:`response` object)
+is a cue to :app:`Pyramid` that it should try to use a :term:`renderer`
+associated with the view configuration to render a response. In our case, the
+renderer used will be the ``templates/view.pt`` template, as indicated in the
+``@view_config`` decorator that is applied to ``view_page()``.
The ``add_page`` view function
------------------------------
@@ -350,20 +346,20 @@ We can finally examine our application in a browser (See
:ref:`wiki2-start-the-application`). Launch a browser and visit
each of the following URLs, check that the result is as expected:
-- ``http://localhost:6543`` in a browser invokes the
+- http://localhost:6543 in a browser invokes the
``view_wiki`` view. This always redirects to the ``view_page`` view
of the FrontPage page object.
-- ``http://localhost:6543/FrontPage`` in a browser invokes
+- http://localhost:6543/FrontPage in a browser invokes
the ``view_page`` view of the front page object.
-- ``http://localhost:6543/FrontPage/edit_page`` in a browser
+- http://localhost:6543/FrontPage/edit_page in a browser
invokes the edit view for the front page object.
-- ``http://localhost:6543/add_page/SomePageName`` in a
+- http://localhost:6543/add_page/SomePageName in a
browser invokes the add view for a page.
-- To generate an error, visit ``http://localhost:6543/foobars/edit_page`` which
+- To generate an error, visit http://localhost:6543/foobars/edit_page which
will generate a ``NoResultFound: No row was found for one()`` error.
You'll see an interactive traceback facility provided
by :term:`pyramid_debugtoolbar`.