diff options
| author | Steve Piercy <web@stevepiercy.com> | 2018-08-18 04:16:15 -0700 |
|---|---|---|
| committer | Steve Piercy <web@stevepiercy.com> | 2018-08-18 04:16:15 -0700 |
| commit | 5ae58c8a28fdf2afa7e60724d25437785e750b01 (patch) | |
| tree | 0bf0e87aa022bca4b6c9e9acba41fca28aad6566 /docs/narr | |
| parent | 1479bdd0231d0595398f44e781f646d2b3a7399d (diff) | |
| download | pyramid-5ae58c8a28fdf2afa7e60724d25437785e750b01.tar.gz pyramid-5ae58c8a28fdf2afa7e60724d25437785e750b01.tar.bz2 pyramid-5ae58c8a28fdf2afa7e60724d25437785e750b01.zip | |
Clean up code-blocks in sessions
Diffstat (limited to 'docs/narr')
| -rw-r--r-- | docs/narr/sessions.rst | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/docs/narr/sessions.rst b/docs/narr/sessions.rst index c0354841c..6c88dcec5 100644 --- a/docs/narr/sessions.rst +++ b/docs/narr/sessions.rst @@ -45,14 +45,14 @@ You can configure this session factory in your :app:`Pyramid` application by using the :meth:`pyramid.config.Configurator.set_session_factory` method. .. code-block:: python - :linenos: + :linenos: - from pyramid.session import SignedCookieSessionFactory - my_session_factory = SignedCookieSessionFactory('itsaseekreet') + from pyramid.session import SignedCookieSessionFactory + my_session_factory = SignedCookieSessionFactory('itsaseekreet') - from pyramid.config import Configurator - config = Configurator() - config.set_session_factory(my_session_factory) + from pyramid.config import Configurator + config = Configurator() + config.set_session_factory(my_session_factory) .. warning:: @@ -81,19 +81,19 @@ session objects provided by the session factory via the ``session`` attribute of any :term:`request` object. For example: .. code-block:: python - :linenos: + :linenos: - from pyramid.response import Response + from pyramid.response import Response - def myview(request): - session = request.session - if 'abc' in session: - session['fred'] = 'yes' - session['abc'] = '123' - if 'fred' in session: - return Response('Fred was in the session') - else: - return Response('Fred was not in the session') + def myview(request): + session = request.session + if 'abc' in session: + session['fred'] = 'yes' + session['abc'] = '123' + if 'fred' in session: + return Response('Fred was in the session') + else: + return Response('Fred was not in the session') The first time this view is invoked produces ``Fred was not in the session``. Subsequent invocations produce ``Fred was in the session``, assuming of course @@ -223,7 +223,7 @@ method: .. code-block:: python - request.session.flash('mymessage') + request.session.flash('mymessage') The ``flash()`` method appends a message to a flash queue, creating the queue if necessary. @@ -246,7 +246,7 @@ represents the default flash message queue. .. code-block:: python - request.session.flash(msg, 'myappsqueue') + request.session.flash(msg, 'myappsqueue') The ``allow_duplicate`` argument defaults to ``True``. If this is ``False``, and you attempt to add a message value which is already present in the queue, |
