From: Tom Hughes Date: Fri, 29 Aug 2014 17:40:08 +0000 (+0100) Subject: Replace deprecated mimetype with content_type X-Git-Tag: live~10 X-Git-Url: https://git.openstreetmap.org./osqa.git/commitdiff_plain/99d077e46d0eb3efd5e96a65f120e6e4b6197db0?ds=sidebyside;hp=524edb6c52ca7f56e9e032a175dc4b7fba0fca6c Replace deprecated mimetype with content_type --- diff --git a/forum/feed.py b/forum/feed.py index c52e64b..810a742 100644 --- a/forum/feed.py +++ b/forum/feed.py @@ -63,7 +63,7 @@ class BaseNodeFeed(Feed): if old_version: def __call__(self, request): feedgen = self.get_feed('') - response = HttpResponse(mimetype=feedgen.mime_type) + response = HttpResponse(content_type=feedgen.mime_type) feedgen.write(response, 'utf-8') return response diff --git a/forum/sitemap.py b/forum/sitemap.py index 26e9d18..0ba045b 100644 --- a/forum/sitemap.py +++ b/forum/sitemap.py @@ -25,7 +25,7 @@ def index(request, sitemaps): sites.append(final_url) xml = loader.render_to_string('sitemap_index.xml', {'sitemaps': sites}) - return HttpResponse(xml, mimetype='application/xml') + return HttpResponse(xml, content_type='application/xml') def sitemap_section_index(request, section, sitemaps): try: @@ -46,7 +46,7 @@ def sitemap_section_index(request, section, sitemaps): locations.append(location) xml = loader.render_to_string('sitemap_section_index.xml', { 'locations' : locations, }) - return HttpResponse(xml, mimetype='application/xml') + return HttpResponse(xml, content_type='application/xml') def sitemap(request, sitemaps, section=None, page=1): maps, urls = [], [] @@ -68,7 +68,7 @@ def sitemap(request, sitemaps, section=None, page=1): except PageNotAnInteger: raise Http404("No page '%s'" % page) xml = smart_str(loader.render_to_string('sitemap.xml', {'urlset': urls})) - return HttpResponse(xml, mimetype='application/xml') + return HttpResponse(xml, content_type='application/xml') class OsqaSitemap(Sitemap): limit = QUESTIONS_SITEMAP_LIMIT diff --git a/forum/utils/decorators.py b/forum/utils/decorators.py index 6cc2d5b..18a5826 100644 --- a/forum/utils/decorators.py +++ b/forum/utils/decorators.py @@ -7,7 +7,7 @@ def ajax_login_required(view_func): return view_func(request,*args,**kwargs) else: json = json.dumps({'login_required':True}) - return HttpResponseForbidden(json, mimetype='application/json') + return HttpResponseForbidden(json, content_type='application/json') return wrap def ajax_method(view_func): @@ -16,10 +16,10 @@ def ajax_method(view_func): raise Http404 retval = view_func(request,*args,**kwargs) if isinstance(retval, HttpResponse): - retval.mimetype = 'application/json' + retval.content_type = 'application/json' return retval else: json = json.dumps(retval) - return HttpResponse(json, mimetype='application/json') + return HttpResponse(json, content_type='application/json') return wrap diff --git a/forum/views/commands.py b/forum/views/commands.py index 62d864f..126faa8 100644 --- a/forum/views/commands.py +++ b/forum/views/commands.py @@ -309,7 +309,7 @@ def node_markdown(request, id): raise AnonymousNotAllowedException(_('accept answers')) node = get_object_or_404(Node, id=id) - return HttpResponse(node.active_revision.body, mimetype="text/plain") + return HttpResponse(node.active_revision.body, content_type="text/plain") @decorate.withfn(command) @@ -547,7 +547,7 @@ def mark_tag(request, tag=None, **kwargs):#tagging system pass else: ts.update(reason=reason) - return HttpResponse(json.dumps(''), mimetype="application/json") + return HttpResponse(json.dumps(''), content_type="application/json") def matching_tags(request): if len(request.GET['q']) == 0: @@ -558,7 +558,7 @@ def matching_tags(request): for tag in possible_tags: tag_output += "%s|%s|%s\n" % (tag.id, tag.name, tag.used_count) - return HttpResponse(tag_output, mimetype="text/plain") + return HttpResponse(tag_output, content_type="text/plain") def matching_users(request): if len(request.GET['q']) == 0: @@ -570,7 +570,7 @@ def matching_users(request): for user in possible_users: output += ("%s|%s|%s\n" % (user.id, user.decorated_name, user.reputation)) - return HttpResponse(output, mimetype="text/plain") + return HttpResponse(output, content_type="text/plain") def related_questions(request): if request.POST and request.POST.get('title', None): @@ -581,7 +581,7 @@ def related_questions(request): return HttpResponse(json.dumps( [dict(title=q.title, url=q.get_absolute_url(), score=q.score, summary=q.summary) - for q in questions.filter_state(deleted=False)[0:10]]), mimetype="application/json") + for q in questions.filter_state(deleted=False)[0:10]]), content_type="application/json") else: raise Http404() diff --git a/forum/views/decorators.py b/forum/views/decorators.py index 3bede66..c99377c 100644 --- a/forum/views/decorators.py +++ b/forum/views/decorators.py @@ -49,7 +49,7 @@ class RefreshPageCommand(HttpResponse): def __init__(self): super(RefreshPageCommand, self).__init__( content=json.dumps({'commands': {'refresh_page': []}, 'success': True}), - mimetype="application/json") + content_type="application/json") def command(func, request, *args, **kwargs): try: @@ -77,7 +77,7 @@ def command(func, request, *args, **kwargs): } if request.is_ajax(): - return HttpResponse(json.dumps(response), mimetype="application/json") + return HttpResponse(json.dumps(response), content_type="application/json") else: return HttpResponseRedirect(request.META.get('HTTP_REFERER', '/')) diff --git a/forum/views/meta.py b/forum/views/meta.py index e7d1515..513fd39 100644 --- a/forum/views/meta.py +++ b/forum/views/meta.py @@ -28,7 +28,7 @@ def favicon(request): return HttpResponseRedirect(str(settings.APP_FAVICON)) def custom_css(request): - return HttpResponse(or_preview(settings.CUSTOM_CSS, request), mimetype="text/css") + return HttpResponse(or_preview(settings.CUSTOM_CSS, request), content_type="text/css") def static(request, title, content): return render_to_response('static.html', {'content' : content, 'title': title}, @@ -146,7 +146,7 @@ def page(request): sidebar = mark_safe(sidebar) else: - return HttpResponse(page.body, mimetype=page.extra.get('mimetype', 'text/html')) + return HttpResponse(page.body, content_type=page.extra.get('mimetype', 'text/html')) render = page.extra.get('render', 'markdown') diff --git a/forum/views/writers.py b/forum/views/writers.py index 597ddba..85f40de 100644 --- a/forum/views/writers.py +++ b/forum/views/writers.py @@ -68,7 +68,7 @@ def upload(request):#ajax upload file to a question or answer except Exception, e: result = xml_template % ('', _('Error uploading file. Please contact the site administrator. Thank you. %s' % e), '') - return HttpResponse(result, mimetype="application/xml") + return HttpResponse(result, content_type="application/xml") def ask(request): form = None diff --git a/forum_modules/akismet/startup.py b/forum_modules/akismet/startup.py index c050754..7600bee 100644 --- a/forum_modules/akismet/startup.py +++ b/forum_modules/akismet/startup.py @@ -51,7 +51,7 @@ def check_spam(param, comment_type): 'success': False, 'error_message': _("Sorry, but akismet thinks your %s is spam.") % comment_type } - return HttpResponse(json.dumps(response), mimetype="application/json") + return HttpResponse(json.dumps(response), content_type="application/json") else: captcha_checked = False try: diff --git a/forum_modules/exporter/views.py b/forum_modules/exporter/views.py index c7b3904..e6cc577 100644 --- a/forum_modules/exporter/views.py +++ b/forum_modules/exporter/views.py @@ -74,7 +74,7 @@ def running(request, mode): }) def state(request): - return HttpResponse(json.dumps(cache.get(CACHE_KEY)), mimetype="application/json") + return HttpResponse(json.dumps(cache.get(CACHE_KEY)), content_type="application/json") @admin_page def download(request): diff --git a/forum_modules/stats/views.py b/forum_modules/stats/views.py index 12a58ab..c052c24 100644 --- a/forum_modules/stats/views.py +++ b/forum_modules/stats/views.py @@ -17,4 +17,4 @@ def stats_index(request): def stats_check(request): update_status = check_for_updates() - return HttpResponse(update_status, mimetype='text/html') + return HttpResponse(update_status, content_type='text/html')