def json_response(message=None, html=None, error=False, login_could_fix=False, **extra): """Returns a JSON response for the JavaScript code. The "wire protocoll" is basically just a JSON object with some common attributes that are checked by the success callback in the JavaScript code before the handler processes it. The `error` and `login_could_fix` keys are internally used by the flashing system on the client. """ extra.update(message=message, html=html, error=error, login_could_fix=login_could_fix) for key, value in extra.iteritems(): extra[key] = remote_export_primitive(value) return Response(dumps(extra), mimetype='application/json')
def send_api_response(request, result): """Sends the API response.""" ro = remote_export_primitive(result) serializer, mimetype = get_serializer(request) return Response(serializer(ro), mimetype=mimetype)