]> git.ozlabs.org Git - patchwork/blobdiff - apps/patchwork/views/xmlrpc.py
xmlrpc: do slice before patch_to_dict
[patchwork] / apps / patchwork / views / xmlrpc.py
index 0d3321fc259d5e431cfc643d7fbd48d850ecf890..283eb34be865fd129c5b1ddcd09328f3fa98e225 100644 (file)
 # Patchwork XMLRPC interface
 #
 
-from django.core.exceptions import ImproperlyConfigured
 from SimpleXMLRPCServer import SimpleXMLRPCDispatcher
 from django.http import HttpResponse, HttpResponseRedirect, \
      HttpResponseServerError
-from django.conf import settings
 from django.core import urlresolvers
-from django.shortcuts import render_to_response
 from django.contrib.auth import authenticate
-from patchwork.models import Patch, Project, Person, Bundle, State
+from patchwork.models import Patch, Project, Person, State
 from django.views.decorators.csrf import csrf_exempt
 
 import sys
@@ -59,14 +56,14 @@ class PatchworkXMLRPCDispatcher(SimpleXMLRPCDispatcher):
 
 
     def _user_for_request(self, request):
-       auth_header = None
+        auth_header = None
 
-        if request.META.has_key('HTTP_AUTHORIZATION'):
-           auth_header = request.META.get('HTTP_AUTHORIZATION')
-        elif request.META.has_key('Authorization'):
-           auth_header = request.META.get('Authorization')
+        if 'HTTP_AUTHORIZATION' in request.META:
+            auth_header = request.META.get('HTTP_AUTHORIZATION')
+        elif 'Authorization' in request.META:
+            auth_header = request.META.get('Authorization')
 
-       if auth_header is None or auth_header == '':
+        if auth_header is None or auth_header == '':
             raise Exception("No authentication credentials given")
 
         str = auth_header.strip()
@@ -132,7 +129,7 @@ def xmlrpc(request):
     try:
         ret = dispatcher._marshaled_dispatch(request)
         response.write(ret)
-    except Exception, e:
+    except Exception:
         return HttpResponseServerError()
 
     return response
@@ -331,7 +328,7 @@ def patch_list(filter={}):
         patches = Patch.objects.filter(**dfilter)
 
         if max_count > 0:
-            return map(patch_to_dict, patches)[:max_count]
+            return map(patch_to_dict, patches[:max_count])
         else:
             return map(patch_to_dict, patches)