summaryrefslogtreecommitdiff
path: root/docs/tutorials/wiki2/definingviews.rst
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2012-12-10 15:34:30 -0500
committerChris McDonough <chrism@plope.com>2012-12-10 15:34:30 -0500
commit8389a5b3339b18f2ba7242d05d11ecb64371f3d9 (patch)
tree113a6b7aea8015518c89cfa42e9bb0df34bed37c /docs/tutorials/wiki2/definingviews.rst
parenta078e197d04400d2430206fe31e3398c761b20a3 (diff)
parentf3a84be3b0e37b74acc26cfb413800610af85b86 (diff)
downloadpyramid-8389a5b3339b18f2ba7242d05d11ecb64371f3d9.tar.gz
pyramid-8389a5b3339b18f2ba7242d05d11ecb64371f3d9.tar.bz2
pyramid-8389a5b3339b18f2ba7242d05d11ecb64371f3d9.zip
Merge branch 'master' of github.com:Pylons/pyramid
Diffstat (limited to 'docs/tutorials/wiki2/definingviews.rst')
-rw-r--r--docs/tutorials/wiki2/definingviews.rst36
1 files changed, 18 insertions, 18 deletions
diff --git a/docs/tutorials/wiki2/definingviews.rst b/docs/tutorials/wiki2/definingviews.rst
index a54996e3c..6b8689b5b 100644
--- a/docs/tutorials/wiki2/definingviews.rst
+++ b/docs/tutorials/wiki2/definingviews.rst
@@ -26,7 +26,7 @@ Declaring Dependencies in Our ``setup.py`` File
The view code in our application will depend on a package which is not a
dependency of the original "tutorial" application. The original "tutorial"
application was generated by the ``pcreate`` command; it doesn't know
-about our custom application requirements.
+about our custom application requirements.
We need to add a dependency on the ``docutils`` package to our ``tutorial``
package's ``setup.py`` file by assigning this dependency to the ``requires`` parameter in ``setup()``.
@@ -123,14 +123,14 @@ the :class:`pyramid.interfaces.IResponse` interface like
It uses the :meth:`pyramid.request.Request.route_url` API to construct a
URL to the ``FrontPage`` page (e.g. ``http://localhost:6543/FrontPage``), which
-is used as the "location" of the HTTPFound response, forming an HTTP redirect.
+is used as the "location" of the ``HTTPFound`` response, forming an HTTP redirect.
The ``view_page`` view function
-------------------------------
``view_page()`` is used to display a single page of our
wiki. It renders the :term:`ReStructuredText` body of a page (stored as
-the ``data`` attribute of a Page object) as HTML. Then it substitutes an
+the ``data`` attribute of a ``Page`` model object) as HTML. Then it substitutes an
HTML anchor for each *WikiWord* reference in the rendered HTML using a
compiled regular expression.
@@ -139,7 +139,7 @@ compiled regular expression.
:linenos:
:language: python
-The curried ``check()`` function is used as the first argument to
+The ``check()`` function is used as the first argument to
``wikiwords.sub``, indicating that it should be called to provide a value for
each WikiWord match found in the content. If the wiki already contains a
page with the matched WikiWord name, ``check()`` generates a view
@@ -181,6 +181,13 @@ the page we'd like to add. If our add view is invoked via,
e.g. ``http://localhost:6543/add_page/SomeName``, the value for
``'pagename'`` in the ``matchdict`` will be ``'SomeName'``.
+If the view execution *is* a result of a form submission (i.e. the expression
+``'form.submitted' in request.params`` is ``True``), we scrape the page body
+from the form data, create a Page object with this page body and the name
+taken from ``matchdict['pagename']``, and save it into the database using
+``DBSession.add``. We then redirect back to the ``view_page`` view for the
+newly created page.
+
If the view execution is *not* a result of a form submission (i.e. the
expression ``'form.submitted' in request.params`` is ``False``), the view
callable renders a template. To do so, it generates a "save url" which the
@@ -191,13 +198,6 @@ in order to satisfy the edit form's desire to have *some* page object
exposed as ``page``. :app:`Pyramid` will render the template associated
with this view to a response.
-If the view execution *is* a result of a form submission (i.e. the expression
-``'form.submitted' in request.params`` is ``True``), we scrape the page body
-from the form data, create a Page object with this page body and the name
-taken from ``matchdict['pagename']``, and save it into the database using
-``DBSession.add``. We then redirect back to the ``view_page`` view for the
-newly created page.
-
The ``edit_page`` view function
-------------------------------
@@ -212,17 +212,17 @@ matching the name of the page the user wants to edit.
:linenos:
:language: python
-If the view execution is *not* a result of a form submission (i.e. the
-expression ``'form.submitted' in request.params`` is ``False``), the view
-simply renders the edit form, passing the page object and a ``save_url``
-which will be used as the action of the generated form.
-
If the view execution *is* a result of a form submission (i.e. the expression
``'form.submitted' in request.params`` is ``True``), the view grabs the
``body`` element of the request parameters and sets it as the ``data``
attribute of the page object. It then redirects to the ``view_page`` view
of the wiki page.
+If the view execution is *not* a result of a form submission (i.e. the
+expression ``'form.submitted' in request.params`` is ``False``), the view
+simply renders the edit form, passing the page object and a ``save_url``
+which will be used as the action of the generated form.
+
Adding Templates
================
@@ -342,7 +342,7 @@ something like:
.. literalinclude:: src/views/tutorial/__init__.py
:linenos:
:language: python
- :emphasize-lines: 17-20
+ :emphasize-lines: 18-21
(The highlighted lines are the ones that need to be added or edited.)
@@ -366,7 +366,7 @@ each of the following URLs, check that the result is as expected:
- ``http://localhost:6543/add_page/SomePageName`` in a
browser invokes the add view for a page.
-- To generate an error, visit ``http://localhost:6543/add_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`.