From 6d1263a97a73d2ced252f93f69c3074a6f3a1056 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Mon, 11 Jul 2011 13:48:27 +0200 Subject: [PATCH] [REM] conditional test, set json-rpc response result directly from method call instead of going through an intermediate variable bzr revid: xmo@openerp.com-20110711114827-od8se08z08qentmm --- openerpweb/openerpweb.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/openerpweb/openerpweb.py b/openerpweb/openerpweb.py index 0ba8648be56..f567cf1b812 100644 --- a/openerpweb/openerpweb.py +++ b/openerpweb/openerpweb.py @@ -280,7 +280,7 @@ class JsonRequest(object): return self.params def dispatch(self, controller, method, requestf=None, request=None): - ''' Calls the method asked for by the JSON-RPC2 request + """ Calls the method asked for by the JSON-RPC2 request :param controller: the instance of the controller which received the request :type controller: type @@ -293,17 +293,19 @@ class JsonRequest(object): :returns: a string-encoded JSON-RPC2 reply :rtype: bytes - ''' + """ # Read POST content or POST Form Data named "request" if requestf: request = simplejson.load(requestf, object_hook=nonliterals.non_literal_decoder) else: request = simplejson.loads(request, object_hook=nonliterals.non_literal_decoder) + + response = {"jsonrpc": "2.0", "id": request.get('id')} try: print "--> %s.%s %s" % (controller.__class__.__name__, method.__name__, request) error = None self.parse(request) - result = method(controller, self, **self.params) + response["result"] = method(controller, self, **self.params) except OpenERPUnboundException: error = { 'code': 100, @@ -335,11 +337,8 @@ class JsonRequest(object): 'debug': "Client %s" % traceback.format_exc() } } - response = {"jsonrpc": "2.0", "id": request.get('id')} if error: response["error"] = error - else: - response["result"] = result print "<--", response print