changeset 9caeb6c884c2 in proteus:4.4
details: https://hg.tryton.org/proteus?cmd=changeset;node=9caeb6c884c2
description:
        Allow to use dict with non string as keys over XML-RPC

        issue8143
        review45961002
        (grafted from 2816e50d03a4e723fc0cbb276bd75e8fa417de8b)
diffstat:

 proteus/config.py |  14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diffs (24 lines):

diff -r 87757ec64494 -r 9caeb6c884c2 proteus/config.py
--- a/proteus/config.py Mon Dec 03 00:48:29 2018 +0100
+++ b/proteus/config.py Fri Mar 08 23:39:15 2019 +0100
@@ -61,6 +61,20 @@
 xmlrpclib.Marshaller.dispatch[bytearray] = dump_bytes
 
 
+def dump_struct(self, value, write, escape=xmlrpc.client.escape):
+    converted_value = {}
+    for k, v in value.items():
+        if isinstance(k, int):
+            k = str(k)
+        elif isinstance(k, float):
+            k = repr(k)
+        converted_value[k] = v
+    return self.dump_struct(converted_value, write, escape=escape)
+
+
+xmlrpc.client.Marshaller.dispatch[dict] = dump_struct
+
+
 class XMLRPCDecoder(object):
 
     decoders = {}

Reply via email to