summaryrefslogtreecommitdiffstats
path: root/apps/patchwork
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2008-09-10 13:21:39 +1000
committerJeremy Kerr <jk@ozlabs.org>2008-09-10 13:21:39 +1000
commit7cc12f61df06e90c09b706dc34007bce099a9350 (patch)
tree2b0d462b519cbdb7c01823c1acdb43fc795a1ad5 /apps/patchwork
parentf69773c2f693da03eeb3334d2b0289d738873c63 (diff)
downloadpatchwork-7cc12f61df06e90c09b706dc34007bce099a9350.tar.bz2
patchwork-7cc12f61df06e90c09b706dc34007bce099a9350.tar.xz
xmlrpc: Fix Python 2.4 compatibility in _marshaled_dispatch
Based on an original patch from Nate Case <ncase@xes-inc.com>. Python 24 doesn't accept encoding and allow_none fields for xmlrpclib.dumps, so abstract this function at dispatcher init time. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'apps/patchwork')
-rw-r--r--apps/patchwork/views/xmlrpc.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/apps/patchwork/views/xmlrpc.py b/apps/patchwork/views/xmlrpc.py
index 245962d..791c89e 100644
--- a/apps/patchwork/views/xmlrpc.py
+++ b/apps/patchwork/views/xmlrpc.py
@@ -39,13 +39,20 @@ class PatchworkXMLRPCDispatcher(SimpleXMLRPCDispatcher):
if sys.version_info[:3] >= (2,5,):
SimpleXMLRPCDispatcher.__init__(self, allow_none=False,
encoding=None)
+ def _dumps(obj, *args, **kwargs):
+ kwargs['allow_none'] = self.allow_none
+ kwargs['encoding'] = self.encoding
+ return xmlrpclib.dumps(obj, *args, **kwargs)
else:
+ def _dumps(obj, *args, **kwargs):
+ return xmlrpclib.dumps(obj, *args, **kwargs)
SimpleXMLRPCDispatcher.__init__(self)
+ 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,
- encoding=self.encoding)
+ response = self.dumps(fault)
except:
# 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