From a5425d62477da1b7cfea5f97fc7e2492a1589cf3 Mon Sep 17 00:00:00 2001 From: LV-426 Date: Mon, 30 Mar 2015 18:24:33 +0300 Subject: __common_resp_handle(): avoid calling jsonify(), handle response building --- src/server/rz_req_handling.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/server/rz_req_handling.py b/src/server/rz_req_handling.py index d34ce2f6..2960874c 100644 --- a/src/server/rz_req_handling.py +++ b/src/server/rz_req_handling.py @@ -20,16 +20,15 @@ def __common_resp_handle(data, error, status): """ return dict(data=data, error=error) - if error is None: - error_str = "" + if not error: + error_str = None else: error_str = str(error) # convert any Exception objects to serializable form ret_data = __response_wrap(data, error_str) - resp = Response(ret_data, mimetype='application/json') + resp_payload = json.dumps(ret_data) + resp = Response(resp_payload, mimetype='application/json', status=status) resp.headers['Access-Control-Allow-Origin'] = '*' - - # jsonify(ret_data) # this will create a Flask Response object # more response processing return resp -- cgit v1.3.1