#NEWLINE# def __init__( self , app = None , key_func = None , global_limits = [ ] , headers_enabled = False , strategy = None , storage_uri = None , storage_options = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , auto_check = True , swallow_errors = False , in_memory_fallback = [ ] , retry_after = None ) : #NEWLINE# #INDENT# self . app = app #NEWLINE# self . logger = logging . getLogger ( 'flask-limiter' ) #NEWLINE# self . enabled = True #NEWLINE# self . _global_limits = [ ] #NEWLINE# self . _in_memory_fallback = [ ] #NEWLINE# self . _exempt_routes = set ( ) #NEWLINE# self . _request_filters = [ ] #NEWLINE# self . _headers_enabled = headers_enabled #NEWLINE# self . _header_mapping = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# self . _retry_after = retry_after #NEWLINE# self . _strategy = strategy #NEWLINE# self . _storage_uri = storage_uri #NEWLINE# self . _storage_options = storage_options #NEWLINE# self . _auto_check = auto_check #NEWLINE# self . _swallow_errors = swallow_errors #NEWLINE# if ( not key_func ) : #NEWLINE# #INDENT# warnings . warn ( 'Use of the default `get_ipaddr` function is discouraged. Please refer to https://flask-limiter.readthedocs.org/#rate-limit-domain for the recommended configuration' , UserWarning ) #NEWLINE# #UNINDENT# self . _key_func = ( key_func or get_ipaddr ) #NEWLINE# for limit in global_limits : #NEWLINE# #INDENT# self . _global_limits . extend ( [ ExtLimit ( limit , self . _key_func , None , False , None , None , None ) for limit in parse_many ( limit ) ] ) #NEWLINE# #UNINDENT# for limit in in_memory_fallback : #NEWLINE# #INDENT# self . _in_memory_fallback . extend ( [ ExtLimit ( limit , self . _key_func , None , False , None , None , None ) for limit in parse_many ( limit ) ] ) #NEWLINE# #UNINDENT# self . _route_limits = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# self . _dynamic_route_limits = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# self . _blueprint_limits = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# self . _blueprint_dynamic_limits = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# self . _blueprint_exempt = set ( ) #NEWLINE# self . _storage = self . _limiter = None #NEWLINE# self . _storage_dead = False #NEWLINE# self . _fallback_limiter = None #NEWLINE# self . __check_backend_count = 0 #NEWLINE# self . __last_check_backend = time . time ( ) #NEWLINE# class BlackHoleHandler ( logging . StreamHandler ) : #NEWLINE# #INDENT# def emit( * _ ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# #UNINDENT# self . logger . addHandler ( BlackHoleHandler ( ) ) #NEWLINE# if app : #NEWLINE# #INDENT# self . init_app ( auto_check )