diff options
author | Jason Gerard DeRose <jderose@redhat.com> | 2009-01-22 15:41:54 -0700 |
---|---|---|
committer | Rob Crittenden <rcritten@redhat.com> | 2009-02-03 15:29:01 -0500 |
commit | 24b6cb89d443384cb432f01265c45bc18d9cf2fc (patch) | |
tree | 50aa6e4b2ce4863d018644026c34085347263c74 /ipalib/rpc.py | |
parent | 9f48612a56b6e760aa06a9af2071f1b50f413f27 (diff) | |
download | freeipa-24b6cb89d443384cb432f01265c45bc18d9cf2fc.tar.gz freeipa-24b6cb89d443384cb432f01265c45bc18d9cf2fc.tar.xz freeipa-24b6cb89d443384cb432f01265c45bc18d9cf2fc.zip |
Further migration toward new xmlrcp code; fixed problem with unicode Fault.faultString; fixed problem where ServerProxy method was not called correctly
Diffstat (limited to 'ipalib/rpc.py')
-rw-r--r-- | ipalib/rpc.py | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/ipalib/rpc.py b/ipalib/rpc.py index e845b8939..aa8002094 100644 --- a/ipalib/rpc.py +++ b/ipalib/rpc.py @@ -135,8 +135,13 @@ def xml_dumps(params, methodname=None, methodresponse=False, encoding='UTF-8'): allow_none=True, ) +def decode_fault(e, encoding='UTF-8'): + assert isinstance(e, Fault) + if type(e.faultString) is str: + return Fault(e.faultCode, e.faultString.decode(encoding)) + return e -def xml_loads(data): +def xml_loads(data, encoding='UTF-8'): """ Decode the XML-RPC packet in ``data``, transparently unwrapping its params. @@ -159,8 +164,11 @@ def xml_loads(data): :param data: The XML-RPC packet to decode. """ - (params, method) = loads(data) - return (xml_unwrap(params), method) + try: + (params, method) = loads(data) + return (xml_unwrap(params), method) + except Fault, e: + raise decode_fault(e) class KerbTransport(SafeTransport): @@ -211,8 +219,8 @@ class xmlclient(Backend): ) ) conn = ServerProxy(self.env.xmlrpc_uri, - transport=KerbTransport(), allow_none=True, + encoding='UTF-8', ) setattr(context, self.connection_name, conn) @@ -243,9 +251,10 @@ class xmlclient(Backend): command = getattr(context.xmlconn, name) params = args + (kw,) try: - response = command(xml_wrap(params)) + response = command(*xml_wrap(params)) return xml_unwrap(response) except Fault, e: + e = decode_fault(e) self.debug('Caught fault %d from server %s: %s', e.faultCode, self.env.xmlrpc_uri, e.faultString) if e.faultCode in self.__errors: |