[virtualcommons-svn] commit/vcweb: alllee: setting content type appropriately for jsonp requests
Status: Beta
Brought to you by:
alllee
From: Bitbucket <com...@bi...> - 2011-07-09 08:05:26
|
1 new changeset in vcweb: http://bitbucket.org/virtualcommons/vcweb/changeset/53acd7144324/ changeset: 53acd7144324 user: alllee date: 2011-07-09 10:05:12 summary: setting content type appropriately for jsonp requests affected #: 1 file (59 bytes) --- a/vcweb/core/views.py Fri Jul 08 16:08:54 2011 -0700 +++ b/vcweb/core/views.py Sat Jul 09 01:05:12 2011 -0700 @@ -7,8 +7,8 @@ from django.db.models.query import QuerySet from django.core.serializers import serialize from django.core.serializers.json import DjangoJSONEncoder -from django.http import HttpResponse -from django.shortcuts import render_to_response, redirect +from django.http import HttpResponse, Http404 +from django.shortcuts import render_to_response, redirect, get_object_or_404 from django.template.context import RequestContext from django.utils.decorators import method_decorator from django.utils.functional import curry @@ -46,11 +46,12 @@ def get_json_response(self, content, **httpresponse_kwargs): "Construct an `HttpResponse` object." callback = self.request.GET.get('callback', '') + content_type = 'application/x-json' if is_valid_jsonp_callback_value(callback): content = '%s(%s)' % (callback, content) - logger.debug("returning json content %s", content) + content_type = 'text/javascript' return HttpResponse(content, - content_type='application/json', + content_type=content_type, **httpresponse_kwargs) def convert_context_to_json(self, context, context_key='object_list', **kwargs): @@ -100,7 +101,7 @@ commons_user = user.experimenter else: logger.error("Invalid user: %s", user) - return + raise Http404 logger.debug("%s authentication_token=%s", commons_user, authentication_token) commons_user.authentication_token = authentication_token commons_user.save() Repository URL: https://bitbucket.org/virtualcommons/vcweb/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. |