diff options
| author | Michael Merickel <github@m.merickel.org> | 2018-08-21 01:44:55 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-08-21 01:44:55 -0500 |
| commit | 820a752645b460ea8009b07a75c752ab09c53dec (patch) | |
| tree | 14616d81a7abedfe523c057e71ed7b2aca680754 /docs/narr/webob.rst | |
| parent | df8598a2658632f709a64e8076cce02ca49de8e6 (diff) | |
| parent | 254710cb716dccfe536b20d077e3cb79be19c6b3 (diff) | |
| download | pyramid-820a752645b460ea8009b07a75c752ab09c53dec.tar.gz pyramid-820a752645b460ea8009b07a75c752ab09c53dec.tar.bz2 pyramid-820a752645b460ea8009b07a75c752ab09c53dec.zip | |
Merge pull request #3330 from stevepiercy/docs-code-style
Docs code style
Diffstat (limited to 'docs/narr/webob.rst')
| -rw-r--r-- | docs/narr/webob.rst | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/docs/narr/webob.rst b/docs/narr/webob.rst index ae76d3500..e78c524ff 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'``. |
