#NEWLINE# def process_exception( self , request , exception ) : #NEWLINE# #INDENT# 'Catches internal Horizon exception classes such as NotAuthorized,\n        NotFound and Http302 and handles them gracefully.\n        ' #NEWLINE# if isinstance ( exception , ( exceptions . NotAuthorized , exceptions . NotAuthenticated ) ) : #NEWLINE# #INDENT# auth_url = settings . LOGIN_URL #NEWLINE# next_url = iri_to_uri ( request . get_full_path ( ) ) #NEWLINE# if ( next_url != auth_url ) : #NEWLINE# #INDENT# field_name = REDIRECT_FIELD_NAME #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# field_name = None #NEWLINE# #UNINDENT# login_url = request . build_absolute_uri ( auth_url ) #NEWLINE# response = redirect_to_login ( next_url , login_url = login_url , redirect_field_name = field_name ) #NEWLINE# if isinstance ( exception , exceptions . NotAuthorized ) : #NEWLINE# #INDENT# logout_reason = _ ( 'Unauthorized. Please try logging in again.' ) #NEWLINE# utils . add_logout_reason ( request , response , logout_reason ) #NEWLINE# response . delete_cookie ( 'messages' ) #NEWLINE# #UNINDENT# if request . is_ajax ( ) : #NEWLINE# #INDENT# response_401 = http . HttpResponse ( status = 401 ) #NEWLINE# response_401 [ 'X-Horizon-Location' ] = response [ 'location' ] #NEWLINE# return response_401 #NEWLINE# #UNINDENT# return response #NEWLINE# #UNINDENT# if isinstance ( exception , exceptions . NotFound ) : #NEWLINE# #INDENT# raise http . Http404 ( exception ) #NEWLINE# #UNINDENT# if isinstance ( exception , exceptions . Http302 ) : #NEWLINE# #INDENT# return shortcuts . redirect ( self . location )