From b1611cf0d24e2947ebfb58071ff7c695a1d824cc Mon Sep 17 00:00:00 2001 From: Patrick Canfield Date: Mon, 18 Mar 2013 13:05:41 -0700 Subject: Update definingviews.rst explain matchdict more explicitly, concisely --- docs/tutorials/wiki2/definingviews.rst | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'docs/tutorials/wiki2/definingviews.rst') diff --git a/docs/tutorials/wiki2/definingviews.rst b/docs/tutorials/wiki2/definingviews.rst index f2ac2f85f..72cba8d1e 100644 --- a/docs/tutorials/wiki2/definingviews.rst +++ b/docs/tutorials/wiki2/definingviews.rst @@ -6,14 +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 +The request object has an attribute named ``matchdict``. A ``matchdict`` maps +the placeholders in the matching URL ``pattern`` to the substrings of the +:term:`request` ed URL. 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'``. -- cgit v1.2.3 From b4eeddf672987c8f03058f5bf0d4f7080007b0e2 Mon Sep 17 00:00:00 2001 From: Patrick Canfield Date: Mon, 18 Mar 2013 14:12:23 -0700 Subject: Update definingviews.rst to be more explicit, concise (?) A make the first sentence a litte more explicit, default to present tense, remove unnecessary details and use python instead of english when it's cleared to do so. --- docs/tutorials/wiki2/definingviews.rst | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'docs/tutorials/wiki2/definingviews.rst') diff --git a/docs/tutorials/wiki2/definingviews.rst b/docs/tutorials/wiki2/definingviews.rst index 72cba8d1e..9df72c926 100644 --- a/docs/tutorials/wiki2/definingviews.rst +++ b/docs/tutorials/wiki2/definingviews.rst @@ -6,14 +6,12 @@ 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 has an attribute named ``matchdict``. A ``matchdict`` maps -the placeholders in the matching URL ``pattern`` to the substrings of the -:term:`request` ed URL. 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 :term:`request` ed URL. For instance, if a call to +:meth:`pyramid.config.Configurator.add_route` has the pattern +``{one}/{two}``, and the URL at ``http://example.com/foo/bar`` is invoked, matching +this pattern, the ``matchdict`` attached to the request would look like: ``{'one':'foo', 'two':'bar'}`` Declaring Dependencies in Our ``setup.py`` File -- cgit v1.2.3 From e163c0931e17c3ad79dd0fa08cea924db1813558 Mon Sep 17 00:00:00 2001 From: Patrick Canfield Date: Mon, 18 Mar 2013 14:16:57 -0700 Subject: Update definingviews.rst to use active voice, reduce redundancy. --- docs/tutorials/wiki2/definingviews.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'docs/tutorials/wiki2/definingviews.rst') diff --git a/docs/tutorials/wiki2/definingviews.rst b/docs/tutorials/wiki2/definingviews.rst index 9df72c926..f733abe10 100644 --- a/docs/tutorials/wiki2/definingviews.rst +++ b/docs/tutorials/wiki2/definingviews.rst @@ -10,8 +10,8 @@ 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 :term:`request` ed URL. For instance, if a call to :meth:`pyramid.config.Configurator.add_route` has the pattern -``{one}/{two}``, and the URL at ``http://example.com/foo/bar`` is invoked, matching -this pattern, the ``matchdict`` attached to the request would look like: ``{'one':'foo', 'two':'bar'}`` +``{one}/{two}``, and a user visits ``http://example.com/foo/bar``, our pattern would be +matched and the ``matchdict`` would look like: ``{'one':'foo', 'two':'bar'}`` Declaring Dependencies in Our ``setup.py`` File -- cgit v1.2.3 From bb8e20e0d35dc806e19edc6d07c837ec272128ec Mon Sep 17 00:00:00 2001 From: Patrick Canfield Date: Mon, 18 Mar 2013 17:24:51 -0700 Subject: Update definingviews.rst to clarify that a template is a renderer --- docs/tutorials/wiki2/definingviews.rst | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'docs/tutorials/wiki2/definingviews.rst') diff --git a/docs/tutorials/wiki2/definingviews.rst b/docs/tutorials/wiki2/definingviews.rst index f733abe10..9894bcb08 100644 --- a/docs/tutorials/wiki2/definingviews.rst +++ b/docs/tutorials/wiki2/definingviews.rst @@ -149,10 +149,9 @@ 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()``. +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 ------------------------------ -- cgit v1.2.3 From e7b21013bab17d5eccdc60f6125cc898996021cf Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Sat, 23 Mar 2013 03:12:42 -0400 Subject: change some slightly awkward wording --- docs/tutorials/wiki2/definingviews.rst | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'docs/tutorials/wiki2/definingviews.rst') diff --git a/docs/tutorials/wiki2/definingviews.rst b/docs/tutorials/wiki2/definingviews.rst index 9894bcb08..53f8e569c 100644 --- a/docs/tutorials/wiki2/definingviews.rst +++ b/docs/tutorials/wiki2/definingviews.rst @@ -6,13 +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 has a dictionary as an attribute named ``matchdict``. -A ``matchdict`` maps the placeholders in the matching URL ``pattern`` to the substrings -of the :term:`request` ed 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 and the ``matchdict`` would look like: ``{'one':'foo', 'two':'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 =============================================== @@ -145,13 +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 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()``. +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 ------------------------------ -- cgit v1.2.3 From 2fe90368e99aedded9177ec222020f6fef81ffed Mon Sep 17 00:00:00 2001 From: Tshepang Lekhonkhobe Date: Sun, 24 Mar 2013 12:07:59 +0200 Subject: make example links clickable, for convenience --- docs/tutorials/wiki2/definingviews.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'docs/tutorials/wiki2/definingviews.rst') diff --git a/docs/tutorials/wiki2/definingviews.rst b/docs/tutorials/wiki2/definingviews.rst index 53f8e569c..a1e2313f3 100644 --- a/docs/tutorials/wiki2/definingviews.rst +++ b/docs/tutorials/wiki2/definingviews.rst @@ -346,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`. -- cgit v1.2.3