Commit 7cc12f61 authored by Jeremy Kerr's avatar Jeremy Kerr
Browse files

xmlrpc: Fix Python 2.4 compatibility in _marshaled_dispatch

Based on an original patch from Nate Case <>.

Python 24 doesn't accept encoding and allow_none fields for
xmlrpclib.dumps, so abstract this function at dispatcher init time.

Signed-off-by: default avatarJeremy Kerr <>
parent f69773c2
......@@ -39,13 +39,20 @@ class PatchworkXMLRPCDispatcher(SimpleXMLRPCDispatcher):
if sys.version_info[:3] >= (2,5,):
SimpleXMLRPCDispatcher.__init__(self, allow_none=False,
def _dumps(obj, *args, **kwargs):
kwargs['allow_none'] = self.allow_none
kwargs['encoding'] = self.encoding
return xmlrpclib.dumps(obj, *args, **kwargs)
def _dumps(obj, *args, **kwargs):
return xmlrpclib.dumps(obj, *args, **kwargs)
self.dumps = _dumps
# map of name => (auth, func)
self.func_map = {}
def register_function(self, fn, auth_required):
self.func_map[fn.__name__] = (auth_required, fn)
......@@ -99,16 +106,13 @@ class PatchworkXMLRPCDispatcher(SimpleXMLRPCDispatcher):
response = self._dispatch(request, method, params)
# wrap response in a singleton tuple
response = (response,)
response = xmlrpclib.dumps(response, methodresponse=1,
allow_none=self.allow_none, encoding=self.encoding)
response = self.dumps(response, methodresponse=1)
except xmlrpclib.Fault, fault:
response = xmlrpclib.dumps(fault, allow_none=self.allow_none,
response = self.dumps(fault)
# report exception back to server
response = xmlrpclib.dumps(
response = self.dumps(
xmlrpclib.Fault(1, "%s:%s" % (sys.exc_type, sys.exc_value)),
encoding=self.encoding, allow_none=self.allow_none,
return response
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment