close Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Changes between Version 1 and Version 2 of SessionState


Ignore:
Timestamp:
Nov 6, 2009, 11:10:24 AM (14 years ago)
Author:
cmlenz
Comment:

Added session usage example

Legend:

Unmodified
Added
Removed
Modified
  • SessionState

    v1 v2  
    99== Usage ==
    1010
     11When the session filter is enabled (which is the default), a plain Python `dict` is made available as the [wiki:ApplicationObject#ApplicationContextVariables application context variable] `app.ctxt.session`. It should usually not be necessary to access that dictionary directly, as the `diva.session` module provides a couple of module-level functions to read, write and delete session data.
     12
     13For example, a simple request handler accessing the session might look like this:
     14
     15{{{
     16#!python
     17from diva import session
     18from diva.templating import output, render
     19
     20@output('test.html')
     21def test(request, response):
     22    cnt = session.get('counter', 0) + 1
     23    session.set('counter', cnt)
     24    return render(counter=cnt)
     25}}}
     26
    1127== API Documentation ==
    1228