<s> from django . shortcuts import render_to_response <EOL> from django . template import RequestContext <EOL> from psycopg2 import OperationalError <EOL> class DatabaseFailureMiddleware ( object ) : <EOL> def process_exception ( self , request , exception ) : <EOL> if isinstance ( exception , OperationalError ) : <EOL> context_dict = { <EOL> '<STR_LIT>' : "<STR_LIT>" , <EOL> '<STR_LIT>' : "<STR_LIT>" <EOL> } <EOL> response = render_to_response ( <EOL> '<STR_LIT>' , <EOL> context_dict , <EOL> context_instance = RequestContext ( request ) <EOL> ) <EOL> response . status_code = <NUM_LIT> <EOL> response . reason_phrase = "<STR_LIT>" <EOL> return response <EOL> return None </s>
