Пример #1
0
 def render_json(self, request, context, template_name):
     context = simplify_value(context)
     resolved = resolve(request.path)
     context['view_name'] = '%s:%s' % (':'.join(
         resolved.namespaces), resolved.url_name)
     return HttpResponse(simplejson.dumps(context),
                         mimetype="application/json")
Пример #2
0
 def render_json(self, request, context, template_name):
     context = simplify_value(context)
     resolved = resolve(request.path)
     context['view_name'] = '%s:%s' % (
         self.conf.application_name.split('.')[-1], resolved.url_name)
     
     # Include CSRF token, as templates don't get rendered csrf_token is
     # never called which breaks CSRF for apps written against the JSON API
     get_token(request)
     
     return HttpResponse(simplejson.dumps(context),
                         mimetype="application/json")
Пример #3
0
    def render_json(self, request, context, template_name):
        context = simplify_value(context)
        resolved = resolve(request.path)
        context['view_name'] = '%s:%s' % (
            self.conf.application_name.split('.')[-1], resolved.url_name)

        # Include CSRF token, as templates don't get rendered csrf_token is
        # never called which breaks CSRF for apps written against the JSON API
        get_token(request)

        return HttpResponse(simplejson.dumps(context),
                            mimetype="application/json")
Пример #4
0
 def render_yaml(self, request, context, template_name):
     import yaml
     context = simplify_value(context)
     return HttpResponse(yaml.safe_dump(context),
                         mimetype="application/x-yaml")
Пример #5
0
 def render_xml(self, request, context, template_name):
     context = simplify_value(context)
     return HttpResponse(
         etree.tostring(serialize_to_xml(context), encoding='UTF-8'),
         mimetype="application/xml")
Пример #6
0
 def render_js(self, request, context, template_name):
     callback = request.GET.get('callback',
                                request.GET.get('jsonp', 'callback'))
     content = simplejson.dumps(simplify_value(context))
     content = "%s(%s);" % (callback, content)
     return HttpResponse(content, mimetype="application/javascript")
Пример #7
0
 def render_json(self, request, context, template_name):
     context = simplify_value(context)
     return HttpResponse(simplejson.dumps(context),
                         mimetype="application/json")
Пример #8
0
 def render_json(self, request, context, template_name):
     context = simplify_value(context)
     resolved = resolve(request.path)
     context['view_name'] = '%s:%s' % (':'.join(resolved.namespaces), resolved.url_name)
     return HttpResponse(simplejson.dumps(context),
                         mimetype="application/json")
Пример #9
0
 def render_yaml(self, request, context, template_name):
     import yaml
     context = simplify_value(context)
     return HttpResponse(yaml.safe_dump(context),
                         mimetype="application/x-yaml")
Пример #10
0
 def render_xml(self, request, context, template_name):
     context = simplify_value(context)
     return HttpResponse(etree.tostring(serialize_to_xml(context),
                                        encoding='UTF-8'),
                         mimetype="application/xml")
Пример #11
0
 def render_js(self, request, context, template_name):
     callback = request.GET.get('callback',
                                request.GET.get('jsonp', 'callback'))
     content = simplejson.dumps(simplify_value(context))
     content = "%s(%s);" % (callback, content)
     return HttpResponse(content, mimetype="application/javascript")