#NEWLINE# def default_setup( config ) : #NEWLINE# #INDENT# "Configure Velruse's session factory and backend storage.\n\n    The default setup uses Pyramid's\n    ``UnencryptedCookieSessionFactoryConfig`` for storing session data.\n\n    Relevant settings:\n\n    ``session.secret`` controls the secret used when signing the session\n    cookies and will be randomly generated if unspecified.\n\n    ``session.cookie_name`` is the name of the cookie stored on a client's\n    browser and will default to 'velruse.session'.\n\n    ``store.*`` settings are used by the `anykeystore` library to construct\n    a storage backend for user credentials. If no storage settings are\n    specified then an in-memory storage backend will be used.\n\n    " #NEWLINE# from pyramid.session import UnencryptedCookieSessionFactoryConfig #NEWLINE# log . info ( 'Using an unencrypted cookie-based session. This can be changed by pointing the "velruse.setup" setting at a different function for configuring the session factory.' ) #NEWLINE# settings = config . registry . settings #NEWLINE# secret = settings . get ( 'session.secret' ) #NEWLINE# cookie_name = settings . get ( 'session.cookie_name' , 'velruse.session' ) #NEWLINE# if ( secret is None ) : #NEWLINE# #INDENT# log . warn ( 'Configuring unencrypted cookie-based session with a random secret which will invalidate old cookies when restarting the app.' ) #NEWLINE# secret = '' . join ( ( ( '%02x' % ord ( x ) ) for x in os . urandom ( 16 ) ) ) #NEWLINE# log . info ( 'autogenerated session secret: %s' , secret ) #NEWLINE# #UNINDENT# factory = UnencryptedCookieSessionFactoryConfig ( secret , cookie_name = cookie_name ) #NEWLINE# config . set_session_factory ( factory ) #NEWLINE# storage_string = settings . get ( 'store' , 'memory' ) #NEWLINE# settings [ 'store.store' ] = storage_string #NEWLINE# store = create_store_from_settings ( settings , prefix = 'store.' ) #NEWLINE# config . register_velruse_store ( store )