pyramid_cubicweb/session.py
author Denis Laxalde <denis.laxalde@logilab.fr>
Wed, 29 Apr 2015 11:39:35 +0200
changeset 11563 f9473eb6a8a9
parent 11537 caf268942436
child 11579 78ba3e88a549
permissions -rw-r--r--
Make debug mode usable without pyramid_debugtoolbar Add the latter in Debian recommends along the way. Closes #5310434.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
11506
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
     1
import warnings
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
     2
import logging
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
     3
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
     4
from pyramid.compat import pickle
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
     5
from pyramid.session import SignedCookieSessionFactory
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
     6
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
     7
from cubicweb import Binary
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
     8
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
     9
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    10
log = logging.getLogger(__name__)
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    11
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    12
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    13
def logerrors(logger):
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    14
    def wrap(fn):
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    15
        def newfn(*args, **kw):
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    16
            try:
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    17
                return fn(*args, **kw)
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    18
            except:
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    19
                logger.exception("Error in %s" % fn.__name__)
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    20
        return newfn
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    21
    return wrap
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    22
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    23
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    24
def CWSessionFactory(
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    25
        secret,
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    26
        cookie_name='session',
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    27
        max_age=None,
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    28
        path='/',
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    29
        domain=None,
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    30
        secure=False,
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    31
        httponly=False,
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    32
        set_on_exception=True,
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    33
        timeout=1200,
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    34
        reissue_time=120,
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    35
        hashalg='sha512',
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    36
        salt='pyramid.session.',
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    37
        serializer=None):
11537
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents: 11506
diff changeset
    38
    """ A pyramid session factory that store session data in the CubicWeb
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents: 11506
diff changeset
    39
    database.
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents: 11506
diff changeset
    40
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents: 11506
diff changeset
    41
    Storage is done with the 'CWSession' entity, which is provided by the
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents: 11506
diff changeset
    42
    'pyramid' cube.
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents: 11506
diff changeset
    43
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents: 11506
diff changeset
    44
    .. warning::
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents: 11506
diff changeset
    45
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents: 11506
diff changeset
    46
        Although it provides a sane default behavior, this session storage has
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents: 11506
diff changeset
    47
        a serious overhead because it uses RQL to access the database.
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents: 11506
diff changeset
    48
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents: 11506
diff changeset
    49
        Using pure SQL would improve a bit (it is roughly twice faster), but it
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents: 11506
diff changeset
    50
        is still pretty slow and thus not an immediate priority.
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents: 11506
diff changeset
    51
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents: 11506
diff changeset
    52
        It is recommended to use faster session factory
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents: 11506
diff changeset
    53
        (pyramid_redis_sessions_ for example) if you need speed.
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents: 11506
diff changeset
    54
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents: 11506
diff changeset
    55
    .. _pyramid_redis_sessions: http://pyramid-redis-sessions.readthedocs.org/
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents: 11506
diff changeset
    56
                                en/latest/index.html
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents: 11506
diff changeset
    57
    """
11506
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    58
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    59
    SignedCookieSession = SignedCookieSessionFactory(
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    60
        secret,
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    61
        cookie_name=cookie_name,
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    62
        max_age=max_age,
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    63
        path=path,
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    64
        domain=domain,
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    65
        secure=secure,
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    66
        httponly=httponly,
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    67
        set_on_exception=set_on_exception,
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    68
        timeout=timeout,
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    69
        reissue_time=reissue_time,
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    70
        hashalg=hashalg,
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    71
        salt=salt,
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    72
        serializer=serializer)
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    73
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    74
    class CWSession(SignedCookieSession):
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    75
        def __init__(self, request):
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    76
            # _set_accessed will be called by the super __init__.
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    77
            # Setting _loaded to True inhibates it.
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    78
            self._loaded = True
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    79
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    80
            # the super __init__ will load a single value in the dictionnary,
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    81
            # the session id.
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    82
            super(CWSession, self).__init__(request)
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    83
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    84
            # Remove the session id from the dict
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    85
            self.sessioneid = self.pop('sessioneid', None)
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    86
            self.repo = request.registry['cubicweb.repository']
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    87
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    88
            # We need to lazy-load only for existing sessions
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    89
            self._loaded = self.sessioneid is None
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    90
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    91
        @logerrors(log)
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    92
        def _set_accessed(self, value):
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    93
            self._accessed = value
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    94
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    95
            if self._loaded:
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    96
                return
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    97
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    98
            with self.repo.internal_cnx() as cnx:
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    99
                session = cnx.find('CWSession', eid=self.sessioneid).one()
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
   100
                value = session.cwsessiondata
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
   101
                if value:
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
   102
                    # Use directly dict.update to avoir _set_accessed to be
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
   103
                    # recursively called
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
   104
                    dict.update(self, pickle.load(value))
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
   105
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
   106
            self._loaded = True
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
   107
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
   108
        def _get_accessed(self):
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
   109
            return self._accessed
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
   110
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
   111
        accessed = property(_get_accessed, _set_accessed)
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
   112
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
   113
        @logerrors(log)
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
   114
        def _set_cookie(self, response):
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
   115
            # Save the value in the database
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
   116
            data = Binary(pickle.dumps(dict(self)))
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
   117
            sessioneid = self.sessioneid
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
   118
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
   119
            with self.repo.internal_cnx() as cnx:
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
   120
                if not sessioneid:
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
   121
                    session = cnx.create_entity(
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
   122
                        'CWSession', cwsessiondata=data)
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
   123
                    sessioneid = session.eid
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
   124
                else:
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
   125
                    session = cnx.entity_from_eid(sessioneid)
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
   126
                    session.cw_set(cwsessiondata=data)
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
   127
                cnx.commit()
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
   128
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
   129
            # Only if needed actually set the cookie
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
   130
            if self.new or self.accessed - self.renewed > self._reissue_time:
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
   131
                dict.clear(self)
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
   132
                dict.__setitem__(self, 'sessioneid', sessioneid)
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
   133
                return super(CWSession, self)._set_cookie(response)
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
   134
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
   135
            return True
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
   136
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
   137
    return CWSession
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
   138
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
   139
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
   140
def includeme(config):
11537
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents: 11506
diff changeset
   141
    """ Activate the CubicWeb session factory.
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents: 11506
diff changeset
   142
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents: 11506
diff changeset
   143
    Usually called via ``config.include('pyramid_cubicweb.auth')``.
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents: 11506
diff changeset
   144
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents: 11506
diff changeset
   145
    See also :ref:`defaults_module`
caf268942436 Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents: 11506
diff changeset
   146
    """
11506
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
   147
    secret = config.registry['cubicweb.config']['pyramid-session-secret']
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
   148
    if not secret:
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
   149
        secret = 'notsosecret'
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
   150
        warnings.warn('''
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
   151
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
   152
            !! WARNING !! !! WARNING !!
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
   153
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
   154
            The session cookies are signed with a static secret key.
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
   155
            To put your own secret key, edit your all-in-one.conf file
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
   156
            and set the 'pyramid-session-secret' key.
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
   157
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
   158
            YOU SHOULD STOP THIS INSTANCE unless your really know what you
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
   159
            are doing !!
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
   160
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
   161
        ''')
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
   162
    session_factory = CWSessionFactory(secret)
bfc1aa1dba30 DB-saved session data
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
   163
    config.set_session_factory(session_factory)