Author: jezdez
Date: 2011-06-28 03:16:47 -0700 (Tue, 28 Jun 2011)
New Revision: 16475

Modified:
   django/trunk/django/contrib/sitemaps/views.py
Log:
Fixed #12347 -- Added a mimetype option to sitemaps views to further customize 
the output of the view, e.g. to support Yahoo's plain text urllist format. 
Thanks, afurlan.

Modified: django/trunk/django/contrib/sitemaps/views.py
===================================================================
--- django/trunk/django/contrib/sitemaps/views.py       2011-06-28 10:16:34 UTC 
(rev 16474)
+++ django/trunk/django/contrib/sitemaps/views.py       2011-06-28 10:16:47 UTC 
(rev 16475)
@@ -5,7 +5,8 @@
 from django.utils.encoding import smart_str
 from django.core.paginator import EmptyPage, PageNotAnInteger
 
-def index(request, sitemaps, template_name='sitemap_index.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,9 +22,10 @@
             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(template_name, {'sitemaps': sites})
-    return HttpResponse(xml, mimetype='application/xml')
+    return HttpResponse(xml, mimetype=mimetype)
 
-def sitemap(request, sitemaps, section=None, template_name='sitemap.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 +45,4 @@
         except PageNotAnInteger:
             raise Http404("No page '%s'" % page)
     xml = smart_str(loader.render_to_string(template_name, {'urlset': urls}))
-    return HttpResponse(xml, mimetype='application/xml')
+    return HttpResponse(xml, mimetype=mimetype)

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to