def _json_response(self, result=None, error=None):
response = {
'jsonrpc': '2.0',
'id': self.jsonrequest.get('id')
}
if error is not None:
response['error'] = error
if result is not None:
response['result'] = result
# Modify start ------------------------------------
if isinstance(result, dict) and result.get('_NAKED_DATA_', False) is True:
response = response['result']
response.pop('_NAKED_DATA_')
# Modify start ------------------------------------
if self.jsonp:
# If we use jsonp, that's mean we are called from another host
# Some browser (IE and Safari) do no allow third party cookies
# We need then to manage http sessions manually.
response['session_id'] = self.session.sid
mime = 'application/javascript'
body = "%s(%s);" % (self.jsonp, json.dumps(response),)
else:
mime = 'application/json'
body = json.dumps(response)
return Response(body, headers=[('Content-Type', mime), ('Content-Length', len(body))])
JsonRequest._json_response = _json_response
return {
"success": True,
"_NAKED_DATA_": True
}