Source code for regcore.responses
import anyjson
from django.http import Http404, HttpResponse
[docs]def user_error(reason):
"""Silly user, you get a 400"""
obj = anyjson.serialize({'reason': reason})
return HttpResponse(obj, 'application/json', 400)
[docs]def success(ret_value=None):
"""Respond with either a JSON message or empty body"""
if ret_value is not None:
return HttpResponse(anyjson.serialize(ret_value), 'application/json')
else:
return HttpResponse('', status=204)
[docs]def four_oh_four():
"""Layer of indirection for 404s. Allows easier migration between web
frameworks"""
raise Http404