Author: ccahoon
Date: 2009-08-02 21:17:12 -0500 (Sun, 02 Aug 2009)
New Revision: 11378

Modified:
   django/branches/soc2009/http-wsgi-improvements/django/shortcuts/__init__.py
   django/branches/soc2009/http-wsgi-improvements/docs/topics/http/shortcuts.txt
Log:
[soc2009/http-wsgi-improvements] Update the render_to_response shortcut to pass 
request and content_type to HttpResponse, to support Accept-Charset. Refs 
#10190.

Also updates docs.

Modified: 
django/branches/soc2009/http-wsgi-improvements/django/shortcuts/__init__.py
===================================================================
--- django/branches/soc2009/http-wsgi-improvements/django/shortcuts/__init__.py 
2009-08-02 23:51:07 UTC (rev 11377)
+++ django/branches/soc2009/http-wsgi-improvements/django/shortcuts/__init__.py 
2009-08-03 02:17:12 UTC (rev 11378)
@@ -11,12 +11,13 @@
 from django.db.models.query import QuerySet
 from django.core import urlresolvers
 
+accepted_kwargs = ('content_type', 'mimetype', 'request')
 def render_to_response(*args, **kwargs):
     """
     Returns a HttpResponse whose content is filled with the result of calling
     django.template.loader.render_to_string() with the passed arguments.
     """
-    httpresponse_kwargs = {'mimetype': kwargs.pop('mimetype', None)}
+    httpresponse_kwargs = dict([(k, kwargs.pop(k, None)) for k in 
accepted_kwargs])
     return HttpResponse(loader.render_to_string(*args, **kwargs), 
**httpresponse_kwargs)
 
 def redirect(to, *args, **kwargs):
@@ -98,4 +99,4 @@
     obj_list = list(queryset.filter(*args, **kwargs))
     if not obj_list:
         raise Http404('No %s matches the given query.' % 
queryset.model._meta.object_name)
-    return obj_list
\ No newline at end of file
+    return obj_list

Modified: 
django/branches/soc2009/http-wsgi-improvements/docs/topics/http/shortcuts.txt
===================================================================
--- 
django/branches/soc2009/http-wsgi-improvements/docs/topics/http/shortcuts.txt   
    2009-08-02 23:51:07 UTC (rev 11377)
+++ 
django/branches/soc2009/http-wsgi-improvements/docs/topics/http/shortcuts.txt   
    2009-08-03 02:17:12 UTC (rev 11378)
@@ -17,7 +17,7 @@
 ``render_to_response``
 ======================
 
-.. function:: render_to_response(template[, dictionary][, context_instance][, 
mimetype])
+.. function:: render_to_response(template[, dictionary][, context_instance][, 
mimetype, content_type, status])
 
    Renders a given template with a given context dictionary and returns an
    :class:`~django.http.HttpResponse` object with that rendered text.
@@ -48,12 +48,25 @@
                                   my_data_dictionary,
                                   context_instance=RequestContext(request))
 
+``content_type``
+    .. versionadded:: 1.2
+
+    The value for the Content-Type header to use in the resulting document. Can
+    also contain a MIME type. Defaults to the value of the 
:setting:`DEFAULT_CONTENT_TYPE` setting.
+
 ``mimetype``
     .. versionadded:: 1.0
 
-    The MIME type to use for the resulting document. Defaults to the value of
+    Alias for content_type, for backwards compatibility. Defaults to the value 
of
     the :setting:`DEFAULT_CONTENT_TYPE` setting.
 
+``request``
+    .. versionadded:: 1.2
+
+    The request can be passed to HttpResponse for handling the Accept-Charset
+    header, which allows clients to specify the encoding in which they wish to
+    receive the content.
+
 Example
 -------
 


--~--~---------~--~----~------------~-------~--~----~
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