From 83e46a9017e734060cdf0f84f4391a5c6a1716aa Mon Sep 17 00:00:00 2001 From: Andrew Williams Date: Thu, 25 Aug 2011 09:49:16 +0100 Subject: [PATCH] Fix UnboundLocalError on EVE API endpoint --- app/api/handlers/v1.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/api/handlers/v1.py b/app/api/handlers/v1.py index 6369ec2..3d3f41c 100644 --- a/app/api/handlers/v1.py +++ b/app/api/handlers/v1.py @@ -92,6 +92,8 @@ class EveAPIHandler(BaseHandler): exclude = ('api_key') def read(self, request): + + s = None if request.GET.get('id', None): s = get_object_or_404(EVEAccount, pk=id) elif request.GET.get('userid', None): @@ -101,7 +103,10 @@ class EveAPIHandler(BaseHandler): elif request.GET.get('allianceid', None): s = EVEAccount.objects.filter(characters__corporation__alliance__id=request.GET['allianceid']) - return {'keys': s.values('api_user_id', 'user_id', 'api_status', 'api_last_updated')} + if s: + return {'keys': s.values('api_user_id', 'user_id', 'api_status', 'api_last_updated')} + + return {'keys': []} class EveAPIProxyHandler(BaseHandler):