<s> """<STR_LIT>""" <EOL> from __future__ import absolute_import <EOL> import threading <EOL> import logging <EOL> from django . conf import settings <EOL> def is_ignorable_404 ( uri ) : <EOL> """<STR_LIT>""" <EOL> return any ( <EOL> pattern . search ( uri ) <EOL> for pattern in getattr ( settings , '<STR_LIT>' , ( ) ) <EOL> ) <EOL> class Sentry404CatchMiddleware ( object ) : <EOL> def process_response ( self , request , response ) : <EOL> from raven . contrib . django . models import client <EOL> if response . status_code != <NUM_LIT> or is_ignorable_404 ( request . get_full_path ( ) ) or not client . is_enabled ( ) : <EOL> return response <EOL> data = client . get_data_from_request ( request ) <EOL> data . update ( { <EOL> '<STR_LIT>' : logging . INFO , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } ) <EOL> result = client . captureMessage ( message = '<STR_LIT>' % request . build_absolute_uri ( ) , data = data ) <EOL> if not result : <EOL> return <EOL> request . sentry = { <EOL> '<STR_LIT>' : data . get ( '<STR_LIT>' , client . remote . project ) , <EOL> '<STR_LIT:id>' : client . get_ident ( result ) , <EOL> } <EOL> return response <EOL> class SentryResponseErrorIdMiddleware ( object ) : <EOL> """<STR_LIT>""" <EOL> def process_response ( self , request , response ) : <EOL> if not getattr ( request , '<STR_LIT>' , None ) : <EOL> return response <EOL> response [ '<STR_LIT>' ] = request . sentry [ '<STR_LIT:id>' ] <EOL> return response <EOL> class SentryLogMiddleware ( object ) : <EOL> thread = threading . local ( ) <EOL> def process_request ( self , request ) : <EOL> self . thread . request = request </s>
