Debian Codegraph @

docs/source/sessions.rst

raw
1 .. _session:
2
3 Working with Sessions and User Authentication
4 =============================================
5
6 Pecan provides no opinionated support for managing user sessions,
7 but it's easy to hook into your session framework of choice with minimal
8 effort.
9
10 This article details best practices for integrating the popular session
11 framework, `Beaker <http://beaker.groovie.org>`_, into your Pecan project.
12
13 Setting up Session Management
14 -----------------------------
15
16 There are several approaches that can be taken to set up session management.
17 One approach is WSGI middleware. Another is Pecan :ref:`hooks`.
18
19 Here's an example of wrapping your WSGI application with Beaker's
20 :class:`~beaker.middleware.SessionMiddleware` in your project's ``app.py``.
21
22 ::
23
24 from pecan import conf, make_app
25 from beaker.middleware import SessionMiddleware
26 from test_project import model
27
28 app = make_app(
29 ...
30 )
31 app = SessionMiddleware(app, conf.beaker)
32
33 And a corresponding dictionary in your configuration file.
34
35 ::
36
37 beaker = {
38 'session.key' : 'sessionkey',
39 'session.type' : 'cookie',
40 'session.validate_key' : '05d2175d1090e31f42fa36e63b8d2aad',
41 '__force_dict__' : True
42 }