from django.core import urlresolvers
from django.contrib.auth import authenticate
from patchwork.models import Patch, Project, Person, State
+from patchwork.views import patch_to_mbox
from django.views.decorators.csrf import csrf_exempt
import sys
def _marshaled_dispatch(self, request):
try:
- params, method = xmlrpclib.loads(request.raw_post_data)
+ params, method = xmlrpclib.loads(request.body)
response = self._dispatch(request, method, params)
# wrap response in a singleton tuple
def person_to_dict(obj):
"""Return a trimmed down dictionary representation of a Person
object which is OK to send to the client."""
+
+ # Make sure we don't return None even if the user submitted a patch
+ # with no real name. XMLRPC can't marshall None.
+ if obj.name is not None:
+ name = obj.name
+ else:
+ name = obj.email
+
return \
{
'id' : obj.id,
'email' : obj.email,
- 'name' : obj.name,
+ 'name' : name,
'user' : unicode(obj.user).encode("utf-8"),
}
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)
"""Return mbox string for the given patch ID."""
try:
patch = Patch.objects.filter(id = patch_id)[0]
- return patch.mbox().as_string()
+ return patch_to_mbox(patch).as_string()
except:
return ""