From c19e6d5b3807e66c17247134097d34f821df8926 Mon Sep 17 00:00:00 2001 From: Mark Huang Date: Fri, 8 Sep 2006 19:43:31 +0000 Subject: [PATCH] - set default byte encodings for DB and XML-RPC/SOAP transactions to UTF-8 --- PLC/API.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/PLC/API.py b/PLC/API.py index 4b192919..80dd8422 100644 --- a/PLC/API.py +++ b/PLC/API.py @@ -5,7 +5,7 @@ # Mark Huang # # Copyright (C) 2004-2006 The Trustees of Princeton University -# $Id$ +# $Id: API.py,v 1.1 2006/09/06 15:36:06 mlhuang Exp $ # import sys @@ -27,7 +27,9 @@ import PLC.Methods class PLCAPI: methods = PLC.Methods.methods - def __init__(self, config = "/etc/planetlab/plc_config"): + def __init__(self, config = "/etc/planetlab/plc_config", encoding = "utf-8"): + self.encoding = encoding + # Better just be documenting the API if config is None: return @@ -100,8 +102,8 @@ class PLCAPI: if interface == xmlrpclib: if not isinstance(result, PLCFault): result = (result,) - data = xmlrpclib.dumps(result, methodresponse = True) + data = xmlrpclib.dumps(result, methodresponse = True, encoding = self.encoding) elif interface == SOAPpy: - data = buildSOAP(kw = {'%sResponse' % method: {'Result': result}}) + data = buildSOAP(kw = {'%sResponse' % method: {'Result': result}}, encoding = self.encoding) return data -- 2.47.0