From 12593859f74d4a851fb233c17a71b4ef7ebc5e90 Mon Sep 17 00:00:00 2001
From: ale <ale@incal.net>
Date: Fri, 20 Jun 2014 23:51:20 +0100
Subject: [PATCH] use current_app, not a specific app

---
 authserv/ratelimit.py | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/authserv/ratelimit.py b/authserv/ratelimit.py
index ff4f6a0..70ee03f 100644
--- a/authserv/ratelimit.py
+++ b/authserv/ratelimit.py
@@ -1,7 +1,6 @@
 import functools
 import re
-from flask import abort, request
-from authserv import app
+from flask import abort, request, current_app
 from authserv import protocol
 
 
@@ -116,8 +115,8 @@ def ratelimit_http_request(key_fn, count=0, period=0):
         @functools.wraps(fn)
         def _ratelimit(*args, **kwargs):
             key = _tostr(key_fn(fn.__name__, args))
-            if key and not rl.check(app.memcache, key):
-                app.logger.debug('ratelimited: %s', key)
+            if key and not rl.check(current_app.memcache, key):
+                current_app.logger.debug('ratelimited: %s', key)
                 abort(503)
             return fn(*args, **kwargs)
         return _ratelimit
@@ -167,12 +166,12 @@ def blacklist_on_auth_failure(key_fn, count=0, period=0, ttl=0, check_wl=False,
                 return fn(*args, **kwargs)
 
             if ((not check_wl or not whitelisted(key))
-                and not bl.check(app.memcache, key)):
-                app.logger.debug('blacklisted %s', key)
+                and not bl.check(current_app.memcache, key)):
+                current_app.logger.debug('blacklisted %s', key)
                 return bl_return_value
             result = fn(*args, **kwargs)
             if result != protocol.OK:
-                bl.incr(app.memcache, key)
+                bl.incr(current_app.memcache, key)
             return result
         return _blacklist
     return decoratorfn
-- 
GitLab