summaryrefslogtreecommitdiff
path: root/docs/tutorials/wiki2/definingviews.rst
diff options
context:
space:
mode:
authorSteve Piercy <web@stevepiercy.com>2015-05-24 19:15:22 -0700
committerSteve Piercy <web@stevepiercy.com>2015-05-24 19:15:22 -0700
commitee9676a8691dd18b88d3247fd8c1306c5aaa1543 (patch)
tree0e323848c78996bb624a6caec7215a3102c94d7b /docs/tutorials/wiki2/definingviews.rst
parentec753b060040a2a6df91341d6d4ed0913761adbc (diff)
downloadpyramid-ee9676a8691dd18b88d3247fd8c1306c5aaa1543.tar.gz
pyramid-ee9676a8691dd18b88d3247fd8c1306c5aaa1543.tar.bz2
pyramid-ee9676a8691dd18b88d3247fd8c1306c5aaa1543.zip
- make templates html5 compliant
- punctuation, grammar, spelling - fix linenos references - update outputs
Diffstat (limited to 'docs/tutorials/wiki2/definingviews.rst')
-rw-r--r--docs/tutorials/wiki2/definingviews.rst46
1 files changed, 23 insertions, 23 deletions
diff --git a/docs/tutorials/wiki2/definingviews.rst b/docs/tutorials/wiki2/definingviews.rst
index 49dbed50f..dd1cb491d 100644
--- a/docs/tutorials/wiki2/definingviews.rst
+++ b/docs/tutorials/wiki2/definingviews.rst
@@ -11,8 +11,8 @@ The request object has a dictionary as an attribute named ``matchdict``. A
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'}``
+against ``/foo/bar`` and the ``matchdict`` would look like ``{'one':'foo',
+'two':'bar'}``.
Declaring Dependencies in Our ``setup.py`` File
===============================================
@@ -32,7 +32,7 @@ Open ``tutorial/setup.py`` and edit it to look like the following:
:language: python
:emphasize-lines: 20
-(Only the highlighted line needs to be added.)
+Only the highlighted line needs to be added.
Running ``setup.py develop``
============================
@@ -71,9 +71,9 @@ It's time for a major change. Open ``tutorial/tutorial/views.py`` and edit it t
.. literalinclude:: src/views/tutorial/views.py
:linenos:
:language: python
- :emphasize-lines: 1-7,12,15-70
+ :emphasize-lines: 1-7,14,16-72
-(The highlighted lines are the ones that need to be added or edited.)
+The highlighted lines are the ones that need to be added or edited.
We got rid of the ``my_view`` view function and its decorator that was
added when we originally rendered the ``alchemy`` scaffold. It was only an
@@ -93,7 +93,7 @@ afterward.
.. note::
There is nothing special about the filename ``views.py``. A project may
- have many view callables throughout its codebase in arbitrarily-named
+ have many view callables throughout its codebase in arbitrarily named
files. Files implementing view callables often have ``view`` in their
filenames (or may live in a Python subpackage of your application package
named ``views``), but this is only by convention.
@@ -106,7 +106,7 @@ is made to the root URL of our wiki. It always redirects to
a URL which represents the path to our "FrontPage".
.. literalinclude:: src/views/tutorial/views.py
- :lines: 18-21
+ :lines: 20-23
:linenos:
:language: python
@@ -116,8 +116,8 @@ the :class:`pyramid.interfaces.IResponse` interface like
:class:`pyramid.response.Response` does).
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.
+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.
The ``view_page`` view function
-------------------------------
@@ -165,25 +165,25 @@ request passed to the ``add_page()`` view will have the values we need
to construct URLs and find model objects.
.. literalinclude:: src/views/tutorial/views.py
- :lines: 45-56
+ :lines: 47-58
:linenos:
:language: python
The ``matchdict`` will have a ``'pagename'`` key that matches the name of
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
+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
+If the view execution *is* a result of a form submission (i.e., the expression
+``'form.submitted' in request.params`` is ``True``), we grab 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
+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
+callable renders a template. To do so, it generates a ``save_url`` which the
template uses as the form post URL during rendering. We're lazy here, so
we're going to use the same template (``templates/edit.pt``) for the add
view as well as the page edit view. To do so we create a dummy Page object
@@ -201,17 +201,17 @@ request passed to the ``edit_page`` view will have a ``'pagename'`` key
matching the name of the page the user wants to edit.
.. literalinclude:: src/views/tutorial/views.py
- :lines: 58-70
+ :lines: 60-72
:linenos:
:language: python
-If the view execution *is* a result of a form submission (i.e. the expression
+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
+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.
@@ -239,12 +239,12 @@ This template is used by ``view_page()`` for displaying a single
wiki page. It includes:
- A ``div`` element that is replaced with the ``content``
- value provided by the view (rows 45-47). ``content``
+ value provided by the view (lines 43-45). ``content``
contains HTML, so the ``structure`` keyword is used
- to prevent escaping it (i.e. changing ">" to "&gt;", etc.)
+ to prevent escaping it (i.e., changing ">" to "&gt;", etc.)
- A link that points
at the "edit" URL which invokes the ``edit_page`` view for
- the page being viewed (rows 49-51).
+ the page being viewed (lines 47-49).
The ``edit.pt`` Template
------------------------
@@ -254,7 +254,7 @@ content:
.. literalinclude:: src/views/tutorial/templates/edit.pt
:linenos:
- :language: xml
+ :language: html
This template is used by ``add_page()`` and ``edit_page()`` for adding
and editing a wiki page. It displays
@@ -265,7 +265,7 @@ a page containing a form that includes:
- A submit button that has the name ``form.submitted`` (row 48).
The form POSTs back to the "save_url" argument supplied
-by the view (row 45). The view will use the ``body`` and
+by the view (row 43). The view will use the ``body`` and
``form.submitted`` values.
.. note:: Our templates use a ``request`` object that