Merge lp:~yann-papouin/ocb-server/6.1-bug-1030795-xmlrpclib-dictkeys-hook into lp:ocb-server/6.1

Proposed by Yann Papouin
Status: Merged
Merged at revision: 4323
Proposed branch: lp:~yann-papouin/ocb-server/6.1-bug-1030795-xmlrpclib-dictkeys-hook
Merge into: lp:ocb-server/6.1
Diff against target: 29 lines (+17/-1)
1 file modified
openerp/wsgi/core.py (+17/-1)
To merge this branch: bzr merge lp:~yann-papouin/ocb-server/6.1-bug-1030795-xmlrpclib-dictkeys-hook
Reviewer Review Type Date Requested Status
Holger Brunn (Therp) code review Approve
Raphaël Valyi - http://www.akretion.com Approve
Alexandre Fayolle - camptocamp code review, no test Approve
Review via email: mp+196512@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote :

LGTM

review: Approve (code review, no test)
Revision history for this message
Raphaël Valyi - http://www.akretion.com (rvalyi) wrote :
review: Approve
Revision history for this message
Holger Brunn (Therp) (hbrunn) :
review: Approve (code review)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'openerp/wsgi/core.py'
--- openerp/wsgi/core.py 2012-05-30 08:12:58 +0000
+++ openerp/wsgi/core.py 2013-11-25 10:48:27 +0000
@@ -75,8 +75,24 @@
75 # RPC_FAULT_CODE_APPLICATION_ERROR value.75 # RPC_FAULT_CODE_APPLICATION_ERROR value.
76 # This also mimics SimpleXMLRPCDispatcher._marshaled_dispatch() for76 # This also mimics SimpleXMLRPCDispatcher._marshaled_dispatch() for
77 # exception handling.77 # exception handling.
78
78 try:79 try:
79 result = openerp.netsvc.dispatch_rpc(service, method, params)80 def fix(res):
81 """
82 This fix is a minor hook to avoid xmlrpclib to raise TypeError exception:
83 - To respect the XML-RPC protocol, all "int" and "float" keys must be cast to string to avoid
84 TypeError, "dictionary key must be string"
85 - And since "allow_none" is disabled, we replace all None values with a False boolean to avoid
86 TypeError, "cannot marshal None unless allow_none is enabled"
87 """
88 if res is None:
89 return False
90 elif type(res) == dict:
91 return dict((str(key), fix(value)) for key, value in res.items())
92 else:
93 return res
94
95 result = fix(openerp.netsvc.dispatch_rpc(service, method, params))
80 response = xmlrpclib.dumps((result,), methodresponse=1, allow_none=False, encoding=None)96 response = xmlrpclib.dumps((result,), methodresponse=1, allow_none=False, encoding=None)
81 except Exception, e:97 except Exception, e:
82 if legacy_exceptions:98 if legacy_exceptions:

Subscribers

People subscribed via source and target branches

to status/vote changes: