summaryrefslogtreecommitdiff
path: root/docs/quick_tutorial
diff options
context:
space:
mode:
authorSteve Piercy <web@stevepiercy.com>2016-04-16 05:17:04 -0700
committerSteve Piercy <web@stevepiercy.com>2016-04-16 05:17:04 -0700
commitff68f90859f01658b397e3559dd1eae0feb508f3 (patch)
treec99824e69ee3fbb8c0ae74528e5bf09034b0f3c5 /docs/quick_tutorial
parent842a4fa23a8948a31023af0983c874ef45cb1041 (diff)
downloadpyramid-ff68f90859f01658b397e3559dd1eae0feb508f3.tar.gz
pyramid-ff68f90859f01658b397e3559dd1eae0feb508f3.tar.bz2
pyramid-ff68f90859f01658b397e3559dd1eae0feb508f3.zip
quick_tutorial cleanup
- replace nose with pytest - cleanup request_response.rst
Diffstat (limited to 'docs/quick_tutorial')
-rw-r--r--docs/quick_tutorial/request_response.rst71
1 files changed, 37 insertions, 34 deletions
diff --git a/docs/quick_tutorial/request_response.rst b/docs/quick_tutorial/request_response.rst
index f42423de8..0ac9b4f6d 100644
--- a/docs/quick_tutorial/request_response.rst
+++ b/docs/quick_tutorial/request_response.rst
@@ -5,33 +5,32 @@
=======================================
Web applications handle incoming requests and return outgoing responses.
-Pyramid makes working with requests and responses convenient and
-reliable.
+Pyramid makes working with requests and responses convenient and reliable.
+
Objectives
==========
-- Learn the background on Pyramid's choices for requests and responses
+- Learn the background on Pyramid's choices for requests and responses.
+
+- Grab data out of the request.
-- Grab data out of the request
+- Change information in the response headers.
-- Change information in the response headers
Background
==========
-Developing for the web means processing web requests. As this is a
-critical part of a web application, web developers need a robust,
-mature set of software for web requests and returning web
-responses.
+Developing for the web means processing web requests. As this is a critical
+part of a web application, web developers need a robust, mature set of software
+for web requests and returning web responses.
+
+Pyramid has always fit nicely into the existing world of Python web development
+(virtual environments, packaging, scaffolding, first to embrace Python 3, and
+so on). Pyramid turned to the well-regarded :term:`WebOb` Python library for
+request and response handling. In our example above, Pyramid hands
+``hello_world`` a ``request`` that is :ref:`based on WebOb <webob_chapter>`.
-Pyramid has always fit nicely into the existing world of Python web
-development (virtual environments, packaging, scaffolding,
-first to embrace Python 3, etc.) For request handling, Pyramid turned
-to the well-regarded :term:`WebOb` Python library for request and
-response handling. In our example
-above, Pyramid hands ``hello_world`` a ``request`` that is
-:ref:`based on WebOb <webob_chapter>`.
Steps
=====
@@ -62,7 +61,9 @@ Steps
.. code-block:: bash
- $ $VENV/bin/nosetests tutorial
+ $ $VENV/bin/py.test tutorial/tests.py -q
+ .....
+ 5 passed in 0.30 seconds
#. Run your Pyramid application with:
@@ -70,37 +71,39 @@ Steps
$ $VENV/bin/pserve development.ini --reload
-#. Open http://localhost:6543/ in your browser. You will be
- redirected to http://localhost:6543/plain
+#. Open http://localhost:6543/ in your browser. You will be redirected to
+ http://localhost:6543/plain.
#. Open http://localhost:6543/plain?name=alice in your browser.
+
Analysis
========
-In this view class we have two routes and two views, with the first
-leading to the second by an HTTP redirect. Pyramid can
-:ref:`generate redirects <http_redirect>` by returning a
-special object from a view or raising a special exception.
+In this view class, we have two routes and two views, with the first leading to
+the second by an HTTP redirect. Pyramid can :ref:`generate redirects
+<http_redirect>` by returning a special object from a view or raising a special
+exception.
+
+In this Pyramid view, we get the URL being visited from ``request.url``. Also,
+if you visited http://localhost:6543/plain?name=alice, the name is included in
+the body of the response:
-In this Pyramid view, we get the URL being visited from ``request.url``.
-Also, if you visited http://localhost:6543/plain?name=alice,
-the name is included in the body of the response::
+.. code-block:: text
URL http://localhost:6543/plain?name=alice with name: alice
-Finally, we set the response's content type and body, then return the
-Response.
+Finally, we set the response's content type and body, then return the response.
+
+We updated the unit and functional tests to prove that our code does the
+redirection, but also handles sending and not sending ``/plain?name``.
-We updated the unit and functional tests to prove that our code
-does the redirection, but also handles sending and not sending
-``/plain?name``.
-Extra Credit
+Extra credit
============
-#. Could we also ``raise HTTPFound(location='/plain')`` instead of
- returning it? If so, what's the difference?
+#. Could we also ``raise HTTPFound(location='/plain')`` instead of returning
+ it? If so, what's the difference?
.. seealso:: :ref:`webob_chapter`,
:ref:`generate redirects <http_redirect>`