Commit 8767439a authored by Adrian Holovaty's avatar Adrian Holovaty
Browse files

Converted some of the built-in views to use content_type instead of mimetype...

Converted some of the built-in views to use content_type instead of mimetype HttpResponse argument. Refs #16519

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17223 bcc190cf-cafb-0310-a4f2-bffc1f526a37
parent d3055b33
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@ def compress_kml(kml):
def render_to_kml(*args, **kwargs):
    "Renders the response as KML (using the correct MIME type)."
    return HttpResponse(loader.render_to_string(*args, **kwargs),
                        mimetype='application/vnd.google-earth.kml+xml')
        content_type='application/vnd.google-earth.kml+xml')

def render_to_kmz(*args, **kwargs):
    """
@@ -28,10 +28,9 @@ def render_to_kmz(*args, **kwargs):
    MIME type).
    """
    return HttpResponse(compress_kml(loader.render_to_string(*args, **kwargs)),
                        mimetype='application/vnd.google-earth.kmz')

        content_type='application/vnd.google-earth.kmz')

def render_to_text(*args, **kwargs):
    "Renders the response using the MIME type for plain text."
    return HttpResponse(loader.render_to_string(*args, **kwargs),
                        mimetype='text/plain')
        content_type='text/plain')
+2 −2
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ def index(request, sitemaps):
            for page in range(2, pages+1):
                sites.append('%s://%s%s?p=%s' % (protocol, current_site.domain, sitemap_url, page))
    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(request, sitemaps, section=None):
    """
@@ -58,7 +58,7 @@ def sitemap(request, sitemaps, section=None):
        except PageNotAnInteger:
            raise Http404("No page '%s'" % page)
    xml = smart_str(loader.render_to_string('gis/sitemaps/geo_sitemap.xml', {'urlset': urls}))
    return HttpResponse(xml, mimetype='application/xml')
    return HttpResponse(xml, content_type='application/xml')

def kml(request, label, model, field_name=None, compress=False, using=DEFAULT_DB_ALIAS):
    """
+5 −8
Original line number Diff line number Diff line
from django.contrib.sites.models import get_current_site
from django.core import urlresolvers
from django.core.paginator import EmptyPage, PageNotAnInteger
from django.http import Http404
from django.template.response import TemplateResponse

from django.contrib.sites.models import get_current_site

def index(request, sitemaps,
        template_name='sitemap_index.xml', mimetype='application/xml'):
def index(request, sitemaps, template_name='sitemap_index.xml', mimetype='application/xml'):
    current_site = get_current_site(request)
    sites = []
    protocol = request.is_secure() and 'https' or 'http'
@@ -21,10 +19,9 @@ def index(request, sitemaps,
        if pages > 1:
            for page in range(2, pages+1):
                sites.append('%s://%s%s?p=%s' % (protocol, current_site.domain, sitemap_url, page))
    return TemplateResponse(request, template_name, {'sitemaps': sites}, mimetype=mimetype)
    return TemplateResponse(request, template_name, {'sitemaps': sites}, content_type=mimetype)

def sitemap(request, sitemaps, section=None,
        template_name='sitemap.xml', mimetype='application/xml'):
def sitemap(request, sitemaps, section=None, template_name='sitemap.xml', mimetype='application/xml'):
    maps, urls = [], []
    if section is not None:
        if section not in sitemaps:
@@ -43,4 +40,4 @@ def sitemap(request, sitemaps, section=None,
            raise Http404("Page %s empty" % page)
        except PageNotAnInteger:
            raise Http404("No page '%s'" % page)
    return TemplateResponse(request, template_name, {'urlset': urls}, mimetype=mimetype)
 No newline at end of file
    return TemplateResponse(request, template_name, {'urlset': urls}, content_type=mimetype)
+1 −1
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@ class Feed(object):
        except ObjectDoesNotExist:
            raise Http404('Feed object does not exist.')
        feedgen = self.get_feed(obj, request)
        response = HttpResponse(mimetype=feedgen.mime_type)
        response = HttpResponse(content_type=feedgen.mime_type)
        feedgen.write(response, 'utf-8')
        return response

+1 −1
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@ def direct_to_template(request, template, extra_context=None, mimetype=None, **k
            dictionary[key] = value
    c = RequestContext(request, dictionary)
    t = loader.get_template(template)
    return HttpResponse(t.render(c), mimetype=mimetype)
    return HttpResponse(t.render(c), content_type=mimetype)

def redirect_to(request, url, permanent=True, query_string=False, **kwargs):
    """
Loading