Example #1
0
File: web.py Project: celery/cyme
def JsonResponse(data, status=http.OK, access_control=None, **kwargs):
    """Returns a JSON encoded response."""
    if isinstance(data, (basestring, int, float, bool)):
        data = {"ok": data}
    if data is None or not isinstance(data, (dict, list, tuple)):
        return data
    kwargs.setdefault("content_type", "application/json")
    response = HttpResponse(serialize(data), status=status, **kwargs)
    set_access_control_options(response, access_control)
    response.csrf_exempt = True
    return response
Example #2
0
def JsonResponse(data, status=http.OK, access_control=None, **kwargs):
    """Returns a JSON encoded response."""
    if isinstance(data, (basestring, int, float, bool)):
        data = {'ok': data}
    if data is None or not isinstance(data, (dict, list, tuple)):
        return data
    kwargs.setdefault('content_type', 'application/json')
    response = HttpResponse(serialize(data),
                            status=status, **kwargs)
    set_access_control_options(response, access_control)
    response.csrf_exempt = True
    return response
 def __call__(self, request):
     # wrap the soaplib response into a Django response object
     django_response = HttpResponse()
     def start_response(status, headers):
         status, reason = status.split(' ', 1)
         django_response.status_code = int(status)
         for header, value in headers:
             django_response[header] = value
     response = super(DjangoSoapApp, self).__call__(request.META, start_response)
     django_response.content = '\n'.join(response)
     django_response.csrf_exempt = True
     return django_response
Example #4
0
    def __call__(self, request):
        # wrap the soaplib response into a Django response object
        django_response = HttpResponse()

        def start_response(status, headers):
            status, reason = status.split(' ', 1)
            django_response.status_code = int(status)
            for header, value in headers:
                django_response[header] = value

        response = super(DjangoSoapApp, self).__call__(request.META,
                                                       start_response)
        django_response.content = '\n'.join(response)
        django_response.csrf_exempt = True
        return django_response