#NEWLINE# def _setup( self ) : #NEWLINE# #INDENT# 'Hook this tool into cherrypy.request.\n\n        The standard CherryPy request object will automatically call this\n        method when the tool is "turned on" in config.\n        ' #NEWLINE# hooks = cherrypy . serving . request . hooks #NEWLINE# conf = self . _merged_args ( ) #NEWLINE# p = conf . pop ( 'priority' , None ) #NEWLINE# if ( p is None ) : #NEWLINE# #INDENT# p = getattr ( self . callable , 'priority' , self . _priority ) #NEWLINE# #UNINDENT# hooks . attach ( self . _point , self . callable , priority = p , ** conf ) #NEWLINE# locking = conf . pop ( 'locking' , 'implicit' ) #NEWLINE# if ( locking == 'implicit' ) : #NEWLINE# #INDENT# hooks . attach ( 'before_handler' , self . _lock_session ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( locking == 'early' ) : #NEWLINE# #INDENT# hooks . attach ( 'before_request_body' , self . _lock_session , priority = 60 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# hooks . attach ( 'before_finalize' , _sessions . save ) #NEWLINE# hooks . attach ( 'on_end_request' , _sessions . close )