#NEWLINE# def _parse_settings( settings ) : #NEWLINE# #INDENT# "\n    Convenience function to collect settings prefixed by 'redis.sessions' and\n    coerce settings to ``int``, ``float``, and ``bool`` as needed.\n    " #NEWLINE# keys = [ s for s in settings if s . startswith ( 'redis.sessions.' ) ] #NEWLINE# options = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for k in keys : #NEWLINE# #INDENT# param = k . split ( '.' ) [ ( - 1 ) ] #NEWLINE# value = settings [ k ] #NEWLINE# options [ param ] = value #NEWLINE# #UNINDENT# if ( 'secret' not in options ) : #NEWLINE# #INDENT# raise ConfigurationError ( 'redis.sessions.secret is a required setting' ) #NEWLINE# #UNINDENT# for b in ( 'cookie_secure' , 'cookie_httponly' , 'cookie_on_exception' ) : #NEWLINE# #INDENT# if ( b in options ) : #NEWLINE# #INDENT# options [ b ] = asbool ( options [ b ] ) #NEWLINE# #UNINDENT# #UNINDENT# for i in ( 'timeout' , 'port' , 'db' , 'cookie_max_age' ) : #NEWLINE# #INDENT# if ( i in b ) : #NEWLINE# #INDENT# options [ i ] = int ( options [ i ] ) #NEWLINE# #UNINDENT# #UNINDENT# if ( 'socket_timeout' in options ) : #NEWLINE# #INDENT# options [ 'socket_timeout' ] = float ( options [ 'socket_timeout' ] ) #NEWLINE# #UNINDENT# if ( ( 'prefix' in options ) and ( 'id_generator' in options ) ) : #NEWLINE# #INDENT# err = 'cannot specify custom id_generator and a key prefix' #NEWLINE# raise ConfigurationError ( err ) #NEWLINE# #UNINDENT# if ( 'prefix' in options ) : #NEWLINE# #INDENT# prefix = options . pop ( 'prefix' ) #NEWLINE# options [ 'id_generator' ] = partial ( prefixed_id , prefix = prefix ) #NEWLINE# #UNINDENT# return options