#NEWLINE# def update_current_session_info( request ) : #NEWLINE# #INDENT# '\n    Maintains and updates last used, ip and user agent fields for\n    current session.\n\n    :type request: django.http.HttpRequest\n    ' #NEWLINE# session_exists = ( request . COOKIES . get ( settings . SESSION_COOKIE_NAME , None ) is not None ) #NEWLINE# if ( not session_exists ) : #NEWLINE# #INDENT# logger . debug ( 'Session does not exist for current request' ) #NEWLINE# return #NEWLINE# #UNINDENT# session = request . session #NEWLINE# now = timezone . now ( ) #NEWLINE# last_used = deserialize_date ( session . get ( SESSION_LAST_USED_KEY , None ) ) #NEWLINE# if ( ( not last_used ) or ( ( now - last_used ) > settings . SESSION_ACTIVITY_UPDATE_THROTTLE ) ) : #NEWLINE# #INDENT# logger . debug ( 'Refreshing session activity' ) #NEWLINE# session [ SESSION_LAST_USED_KEY ] = serialize_date ( now ) #NEWLINE# session [ SESSION_IP_KEY ] = request . META [ 'REMOTE_ADDR' ] #NEWLINE# session [ SESSION_USER_AGENT_KEY ] = request . META . get ( 'HTTP_USER_AGENT' , '' ) #NEWLINE# user = request . user #NEWLINE# if user . is_authenticated ( ) : #NEWLINE# #INDENT# if ( not SessionActivity . objects . filter ( user = user , session_key = session . session_key ) . exists ( ) ) : #NEWLINE# #INDENT# create_session_activity ( request = request , user = user )