pyramid_cubicweb/session.py
changeset 11537 caf268942436
parent 11506 bfc1aa1dba30
child 11579 78ba3e88a549
equal deleted inserted replaced
11536:6618408c0629 11537:caf268942436
    33         timeout=1200,
    33         timeout=1200,
    34         reissue_time=120,
    34         reissue_time=120,
    35         hashalg='sha512',
    35         hashalg='sha512',
    36         salt='pyramid.session.',
    36         salt='pyramid.session.',
    37         serializer=None):
    37         serializer=None):
       
    38     """ A pyramid session factory that store session data in the CubicWeb
       
    39     database.
       
    40 
       
    41     Storage is done with the 'CWSession' entity, which is provided by the
       
    42     'pyramid' cube.
       
    43 
       
    44     .. warning::
       
    45 
       
    46         Although it provides a sane default behavior, this session storage has
       
    47         a serious overhead because it uses RQL to access the database.
       
    48 
       
    49         Using pure SQL would improve a bit (it is roughly twice faster), but it
       
    50         is still pretty slow and thus not an immediate priority.
       
    51 
       
    52         It is recommended to use faster session factory
       
    53         (pyramid_redis_sessions_ for example) if you need speed.
       
    54 
       
    55     .. _pyramid_redis_sessions: http://pyramid-redis-sessions.readthedocs.org/
       
    56                                 en/latest/index.html
       
    57     """
    38 
    58 
    39     SignedCookieSession = SignedCookieSessionFactory(
    59     SignedCookieSession = SignedCookieSessionFactory(
    40         secret,
    60         secret,
    41         cookie_name=cookie_name,
    61         cookie_name=cookie_name,
    42         max_age=max_age,
    62         max_age=max_age,
   116 
   136 
   117     return CWSession
   137     return CWSession
   118 
   138 
   119 
   139 
   120 def includeme(config):
   140 def includeme(config):
       
   141     """ Activate the CubicWeb session factory.
       
   142 
       
   143     Usually called via ``config.include('pyramid_cubicweb.auth')``.
       
   144 
       
   145     See also :ref:`defaults_module`
       
   146     """
   121     secret = config.registry['cubicweb.config']['pyramid-session-secret']
   147     secret = config.registry['cubicweb.config']['pyramid-session-secret']
   122     if not secret:
   148     if not secret:
   123         secret = 'notsosecret'
   149         secret = 'notsosecret'
   124         warnings.warn('''
   150         warnings.warn('''
   125 
   151