From 6316c45df2f2a545d003d6ec51bba05e4b0f6bad Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=2E=C3=87a=C4=9Flar=20Onur?= Date: Wed, 17 Nov 2010 16:21:01 -0500 Subject: [PATCH] handle KeyError exception for now --- aspects/ratelimitaspects.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/aspects/ratelimitaspects.py b/aspects/ratelimitaspects.py index 07ccfc6d..dbe02424 100644 --- a/aspects/ratelimitaspects.py +++ b/aspects/ratelimitaspects.py @@ -40,13 +40,18 @@ class BaseRateLimit(object): api_method_name = wobj.name api_method_source = wobj.source - api_method_caller = args[0]["Username"] + + # FIXME: Support SessionAuth, GPGAuth, BootAuth and AnonymousAuth + try: + api_method_caller = args[0]["Username"] + except KeyError: + api_method_caller = "_" if api_method_source == None or api_method_source[0] == self.config.PLC_API_IP or api_method_source[0] in self.whitelist: return if api_method_caller == None: - self.log("%s called with Username = None" % api_method_source[0]) + self.log("%s called from %s with Username = None" % (api_method_name, api_method_source[0])) return mc = memcache.Client(["%s:11211" % self.config.PLC_API_HOST]) -- 2.47.0