<s> from django . shortcuts import render , redirect <EOL> from django . conf import settings <EOL> from downtime . models import Period <EOL> class DowntimeMiddleware ( object ) : <EOL> def process_request ( self , request ) : <EOL> exempt_exact_urls = getattr ( settings , <EOL> '<STR_LIT>' , None ) <EOL> if exempt_exact_urls : <EOL> for url in exempt_exact_urls : <EOL> if request . path == url : <EOL> return None <EOL> exempt_paths = getattr ( settings , '<STR_LIT>' , ( '<STR_LIT>' , ) ) <EOL> for path in exempt_paths : <EOL> if request . path . startswith ( path ) : <EOL> return None <EOL> objects = Period . objects . is_down ( ) <EOL> if objects . count ( ) : <EOL> url_redirect = getattr ( settings , '<STR_LIT>' , None ) <EOL> if url_redirect : <EOL> return redirect ( url_redirect ) <EOL> else : <EOL> return render ( request , "<STR_LIT>" , status = <NUM_LIT> ) </s>
