SessionsΒΆ

Fresco does not provide any session management itself, but integrates easily with beaker or other session management packages. For example:

from beaker.middleware import SessionMiddleware
from fresco import FrescoApp

session_opts = {'session.type': 'file',
                'session.auto': True,
                'session.data_dir': '/tmp/session-data'}

app = FrescoApp()
app.add_middleware(SessionMiddleware, session_opts)

The session can then be accessed via context.request.session, eg:

def myview():
    session = context.request.session
    count = session.get('count', 0)
    session['count'] = count + 1
    return Response(['Count is %d' % count])

Fresco is pre-configured to work with beaker. If you prefer to use a different package, normally all that is required is to change the value of Request.SESSION_ENV_KEY. For example:

Request.SESSION_ENV_KEY = 'com.saddi.service.session'