#NEWLINE# def update( self , force = False ) : #NEWLINE# #INDENT# 'extend session expiry' #NEWLINE# if ( ( frappe . session [ 'user' ] == 'Guest' ) or ( frappe . form_dict . cmd == 'logout' ) ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# now = frappe . utils . now ( ) #NEWLINE# self . data [ 'data' ] [ 'last_updated' ] = now #NEWLINE# self . data [ 'data' ] [ 'lang' ] = unicode ( frappe . lang ) #NEWLINE# last_updated = frappe . cache ( ) . hget ( 'last_db_session_update' , self . sid ) #NEWLINE# time_diff = ( frappe . utils . time_diff_in_seconds ( now , last_updated ) if last_updated else None ) #NEWLINE# updated_in_db = False #NEWLINE# if ( force or ( time_diff == None ) or ( time_diff > 600 ) ) : #NEWLINE# #INDENT# frappe . db . sql ( 'update tabSessions set sessiondata=%s,\n\t\t\t\tlastupdate=NOW() where sid=%s' , ( str ( self . data [ 'data' ] ) , self . data [ 'sid' ] ) ) #NEWLINE# frappe . db . sql ( 'update `tabUser` set last_active=%(now)s where name=%(name)s' , { #NEWLINE# #INDENT# 'now' : frappe . utils . now ( ) , #NEWLINE# 'name' : frappe . session . user , #NEWLINE# #UNINDENT# } ) #NEWLINE# frappe . cache ( ) . hset ( 'last_db_session_update' , self . sid , now ) #NEWLINE# updated_in_db = True #NEWLINE# #UNINDENT# frappe . cache ( ) . hset ( 'session' , self . sid , self . data ) #NEWLINE# return updated_in_db