Author: adrian
Date: 2006-05-31 10:08:06 -0500 (Wed, 31 May 2006)
New Revision: 3022

Modified:
   django/trunk/django/views/generic/date_based.py
   django/trunk/django/views/generic/list_detail.py
   django/trunk/docs/generic_views.txt
Log:
Fixed #2000 -- Added 'mimetype' parameter to generic views. Thanks, Ian Holsman

Modified: django/trunk/django/views/generic/date_based.py
===================================================================
--- django/trunk/django/views/generic/date_based.py     2006-05-31 14:58:20 UTC 
(rev 3021)
+++ django/trunk/django/views/generic/date_based.py     2006-05-31 15:08:06 UTC 
(rev 3022)
@@ -6,7 +6,8 @@
 
 def archive_index(request, queryset, date_field, num_latest=15,
         template_name=None, template_loader=loader,
-        extra_context={}, allow_empty=False, context_processors=None):
+        extra_context={}, allow_empty=False, context_processors=None,
+        mimetype=None):
     """
     Generic top-level archive of date-based objects.
 
@@ -40,11 +41,11 @@
             c[key] = value()
         else:
             c[key] = value
-    return HttpResponse(t.render(c))
+    return HttpResponse(t.render(c), mimetype=mimetype)
 
 def archive_year(request, year, queryset, date_field, template_name=None,
         template_loader=loader, extra_context={}, allow_empty=False,
-        context_processors=None):
+        context_processors=None, mimetype=None):
     """
     Generic yearly archive view.
 
@@ -78,12 +79,12 @@
             c[key] = value()
         else:
             c[key] = value
-    return HttpResponse(t.render(c))
+    return HttpResponse(t.render(c), mimetype=mimetype)
 
 def archive_month(request, year, month, queryset, date_field,
         month_format='%b', template_name=None, template_loader=loader,
         extra_context={}, allow_empty=False, context_processors=None,
-        template_object_name='object'):
+        template_object_name='object', mimetype=None):
     """
     Generic monthly archive view.
 
@@ -134,12 +135,12 @@
             c[key] = value()
         else:
             c[key] = value
-    return HttpResponse(t.render(c))
+    return HttpResponse(t.render(c), mimetype=mimetype)
 
 def archive_week(request, year, week, queryset, date_field,
         template_name=None, template_loader=loader,
         extra_context={}, allow_empty=True, context_processors=None,
-        template_object_name='object'):
+        template_object_name='object', mimetype=None):
     """
     Generic weekly archive view.
 
@@ -181,12 +182,13 @@
             c[key] = value()
         else:
             c[key] = value
-    return HttpResponse(t.render(c))
+    return HttpResponse(t.render(c), mimetype=mimetype)
 
 def archive_day(request, year, month, day, queryset, date_field,
         month_format='%b', day_format='%d', template_name=None,
         template_loader=loader, extra_context={}, allow_empty=False,
-        context_processors=None, template_object_name='object'):
+        context_processors=None, template_object_name='object',
+        mimetype=None):
     """
     Generic daily archive view.
 
@@ -233,7 +235,7 @@
             c[key] = value()
         else:
             c[key] = value
-    return HttpResponse(t.render(c))
+    return HttpResponse(t.render(c), mimetype=mimetype)
 
 def archive_today(request, **kwargs):
     """
@@ -251,7 +253,7 @@
         month_format='%b', day_format='%d', object_id=None, slug=None,
         slug_field=None, template_name=None, template_name_field=None,
         template_loader=loader, extra_context={}, context_processors=None,
-        template_object_name='object'):
+        template_object_name='object', mimetype=None):
     """
     Generic detail view from year/month/day/slug or year/month/day/id 
structure.
 
@@ -300,6 +302,6 @@
             c[key] = value()
         else:
             c[key] = value
-    response = HttpResponse(t.render(c))
+    response = HttpResponse(t.render(c), mimetype=mimetype)
     populate_xheaders(request, response, model, getattr(obj, 
obj._meta.pk.name))
     return response

Modified: django/trunk/django/views/generic/list_detail.py
===================================================================
--- django/trunk/django/views/generic/list_detail.py    2006-05-31 14:58:20 UTC 
(rev 3021)
+++ django/trunk/django/views/generic/list_detail.py    2006-05-31 15:08:06 UTC 
(rev 3022)
@@ -6,7 +6,8 @@
 
 def object_list(request, queryset, paginate_by=None, allow_empty=False,
         template_name=None, template_loader=loader,
-        extra_context={}, context_processors=None, 
template_object_name='object'):
+        extra_context={}, context_processors=None, 
template_object_name='object',
+        mimetype=None):
     """
     Generic list of objects.
 
@@ -73,12 +74,13 @@
         model = queryset.model
         template_name = "%s/%s_list.html" % (model._meta.app_label, 
model._meta.object_name.lower())
     t = template_loader.get_template(template_name)
-    return HttpResponse(t.render(c))
+    return HttpResponse(t.render(c), mimetype=mimetype)
 
 def object_detail(request, queryset, object_id=None, slug=None,
         slug_field=None, template_name=None, template_name_field=None,
         template_loader=loader, extra_context={},
-        context_processors=None, template_object_name='object'):
+        context_processors=None, template_object_name='object',
+        mimetype=None):
     """
     Generic list of objects.
 
@@ -113,6 +115,6 @@
             c[key] = value()
         else:
             c[key] = value
-    response = HttpResponse(t.render(c))
+    response = HttpResponse(t.render(c), mimetype=mimetype)
     populate_xheaders(request, response, model, getattr(obj, 
obj._meta.pk.name))
     return response

Modified: django/trunk/docs/generic_views.txt
===================================================================
--- django/trunk/docs/generic_views.txt 2006-05-31 14:58:20 UTC (rev 3021)
+++ django/trunk/docs/generic_views.txt 2006-05-31 15:08:06 UTC (rev 3022)
@@ -182,6 +182,9 @@
     * ``context_processors``: A list of template-context processors to apply to
       the view's template. See the `RequestContext docs`_.
 
+    * ``mimetype``: The MIME type to use for the resulting document. Defaults
+      to the value of the ``DEFAULT_MIME_TYPE`` setting.
+
 **Template name:**
 
 If ``template_name`` isn't specified, this view will use the template
@@ -247,6 +250,9 @@
     * ``context_processors``: A list of template-context processors to apply to
       the view's template. See the `RequestContext docs`_.
 
+    * ``mimetype``: The MIME type to use for the resulting document. Defaults
+      to the value of the ``DEFAULT_MIME_TYPE`` setting.
+
 **Template name:**
 
 If ``template_name`` isn't specified, this view will use the template
@@ -314,6 +320,9 @@
        view will append ``'_list'`` to the value of this parameter in
        determining the variable's name.
 
+    * ``mimetype``: The MIME type to use for the resulting document. Defaults
+      to the value of the ``DEFAULT_MIME_TYPE`` setting.
+
 **Template name:**
 
 If ``template_name`` isn't specified, this view will use the template
@@ -387,6 +396,9 @@
        view will append ``'_list'`` to the value of this parameter in
        determining the variable's name.
 
+    * ``mimetype``: The MIME type to use for the resulting document. Defaults
+      to the value of the ``DEFAULT_MIME_TYPE`` setting.
+
 **Template name:**
 
 If ``template_name`` isn't specified, this view will use the template
@@ -463,6 +475,9 @@
        view will append ``'_list'`` to the value of this parameter in
        determining the variable's name.
 
+    * ``mimetype``: The MIME type to use for the resulting document. Defaults
+      to the value of the ``DEFAULT_MIME_TYPE`` setting.
+
 **Template name:**
 
 If ``template_name`` isn't specified, this view will use the template
@@ -563,6 +578,9 @@
     * ``template_object_name``:  Designates the name of the template variable
        to use in the template context. By default, this is ``'object'``.
 
+    * ``mimetype``: The MIME type to use for the resulting document. Defaults
+      to the value of the ``DEFAULT_MIME_TYPE`` setting.
+
 **Template name:**
 
 If ``template_name`` isn't specified, this view will use the template
@@ -627,6 +645,9 @@
        view will append ``'_list'`` to the value of this parameter in
        determining the variable's name.
 
+    * ``mimetype``: The MIME type to use for the resulting document. Defaults
+      to the value of the ``DEFAULT_MIME_TYPE`` setting.
+
 **Template name:**
 
 If ``template_name`` isn't specified, this view will use the template
@@ -717,6 +738,9 @@
     * ``template_object_name``:  Designates the name of the template variable
        to use in the template context. By default, this is ``'object'``.
 
+    * ``mimetype``: The MIME type to use for the resulting document. Defaults
+      to the value of the ``DEFAULT_MIME_TYPE`` setting.
+
 **Template name:**
 
 If ``template_name`` isn't specified, this view will use the template


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates
-~----------~----~----~----~------~----~------~--~---

Reply via email to