summaryrefslogtreecommitdiff
path: root/docs/narr/webob.rst
diff options
context:
space:
mode:
authorSteve Piercy <web@stevepiercy.com>2018-08-18 04:39:40 -0700
committerSteve Piercy <web@stevepiercy.com>2018-08-18 04:39:40 -0700
commit95f26f1fdb70a8428c0bba8faac8602987b33f6f (patch)
tree648c0f4b79397e73c0aa99993e9432c779f47397 /docs/narr/webob.rst
parentfdf6bb3b4ee831f9831326d7c5d30baad3e68b9b (diff)
downloadpyramid-95f26f1fdb70a8428c0bba8faac8602987b33f6f.tar.gz
pyramid-95f26f1fdb70a8428c0bba8faac8602987b33f6f.tar.bz2
pyramid-95f26f1fdb70a8428c0bba8faac8602987b33f6f.zip
Clean up code-blocks in webob
Diffstat (limited to 'docs/narr/webob.rst')
-rw-r--r--docs/narr/webob.rst28
1 files changed, 14 insertions, 14 deletions
diff --git a/docs/narr/webob.rst b/docs/narr/webob.rst
index 4efe783b0..95fc8eb5c 100644
--- a/docs/narr/webob.rst
+++ b/docs/narr/webob.rst
@@ -252,8 +252,8 @@ Using ``request.json_body`` is equivalent to:
.. code-block:: python
- from json import loads
- loads(request.body, encoding=request.charset)
+ from json import loads
+ loads(request.body, encoding=request.charset)
Here's how to construct an AJAX request in JavaScript using :term:`jQuery` that
allows you to use the ``request.json_body`` attribute when the request is sent
@@ -321,19 +321,19 @@ session to be removed after each request. Put the following in the
``mypackage.__init__`` module:
.. code-block:: python
- :linenos:
+ :linenos:
- from mypackage.models import DBSession
+ from mypackage.models import DBSession
- from pyramid.events import subscriber
- from pyramid.events import NewRequest
+ from pyramid.events import subscriber
+ from pyramid.events import NewRequest
- def cleanup_callback(request):
- DBSession.remove()
+ def cleanup_callback(request):
+ DBSession.remove()
- @subscriber(NewRequest)
- def add_cleanup_callback(event):
- event.request.add_finished_callback(cleanup_callback)
+ @subscriber(NewRequest)
+ def add_cleanup_callback(event):
+ event.request.add_finished_callback(cleanup_callback)
Registering the ``cleanup_callback`` finished callback at the start of a
request (by causing the ``add_cleanup_callback`` to receive a
@@ -450,10 +450,10 @@ attribute of the response can be passed in as a keyword argument to the class,
e.g.:
.. code-block:: python
- :linenos:
+ :linenos:
- from pyramid.response import Response
- response = Response(body='hello world!', content_type='text/plain')
+ from pyramid.response import Response
+ response = Response(body='hello world!', content_type='text/plain')
The status defaults to ``'200 OK'``.