openerp-community-reviewer team mailing list archive
-
openerp-community-reviewer team
-
Mailing list archive
-
Message #01649
lp:~yann-papouin/ocb-server/7.0-bug-1030795-xmlrpclib-dictkeys-hook into lp:ocb-server
Yann Papouin has proposed merging lp:~yann-papouin/ocb-server/7.0-bug-1030795-xmlrpclib-dictkeys-hook into lp:ocb-server.
Requested reviews:
OpenERP Community Backports Team (ocb)
Related bugs:
Bug #1030795 in OpenERP Community Backports (Server): "stock_picking.action_invoice_create: calling by xmlrpc raises TypeError"
https://bugs.launchpad.net/ocb-server/+bug/1030795
Bug #1249355 in OpenERP Server: "XML-RPC object service tries to return non-XML-RPC conformant replies"
https://bugs.launchpad.net/openobject-server/+bug/1249355
For more details, see:
https://code.launchpad.net/~yann-papouin/ocb-server/7.0-bug-1030795-xmlrpclib-dictkeys-hook/+merge/196519
Automatically derived from https://code.launchpad.net/~yann-papouin/openobject-server/7.0-bug-1030795-xmlrpclib-dictkeys-hook for https://code.launchpad.net/~openerp/openobject-server/7.0.
--
https://code.launchpad.net/~yann-papouin/ocb-server/7.0-bug-1030795-xmlrpclib-dictkeys-hook/+merge/196519
Your team OpenERP Community Backports Team is requested to review the proposed merge of lp:~yann-papouin/ocb-server/7.0-bug-1030795-xmlrpclib-dictkeys-hook into lp:ocb-server.
=== modified file 'openerp/service/wsgi_server.py'
--- openerp/service/wsgi_server.py 2013-03-01 12:07:44 +0000
+++ openerp/service/wsgi_server.py 2013-11-25 11:10:44 +0000
@@ -79,7 +79,22 @@
# This also mimics SimpleXMLRPCDispatcher._marshaled_dispatch() for
# exception handling.
try:
- result = openerp.netsvc.dispatch_rpc(service, method, params)
+ def fix(res):
+ """
+ This fix is a minor hook to avoid xmlrpclib to raise TypeError exception:
+ - To respect the XML-RPC protocol, all "int" and "float" keys must be cast to string to avoid
+ TypeError, "dictionary key must be string"
+ - And since "allow_none" is disabled, we replace all None values with a False boolean to avoid
+ TypeError, "cannot marshal None unless allow_none is enabled"
+ """
+ if res is None:
+ return False
+ elif type(res) == dict:
+ return dict((str(key), fix(value)) for key, value in res.items())
+ else:
+ return res
+
+ result = fix(openerp.netsvc.dispatch_rpc(service, method, params))
response = xmlrpclib.dumps((result,), methodresponse=1, allow_none=False, encoding=None)
except Exception, e:
if legacy_exceptions:
Follow ups