On 11/28/2010 10:13 AM, Russell Keith-Magee wrote:
For your consideration, I present a patch to resolve #12815 and
#12816, adding a TemplateResponse and a render() shortcut.

Thank you!

  - The render() shortcut doesn't use TemplateResponse. Since render()
and TemplateReponse() have exactly the same prototype, I didn't see
the value in adding a shortcut that just redirected to a different
constructor. However, there is still value in making an easy-to-use
render_to_response, for those situations where a TemplateResponse
can't be used.

I have a slight (about -0) concern about this… It might turned out as the same mistake that was made with render_to_response() in the first place: it wasn't powerful enough (i.e. it didn't use RequestContext) to be used as a default shortcut. If people would like TemplateResponse they would be frustrated that render() doesn't use it. Using TemplateResponse directly is perfectly possible but then we have to explain to every newcomer why are there two slightly different ways of doing one thing. I think that cases where one wants to care about using pure HttpResponse instead of TemplateResponse would be rare and it's better not be the default behavior.

P.S. Noticed a typo in the patch:

@@ -164,6 +154,13 @@
             urlresolvers.set_urlconf(None)

         try:
+            # Apply template response middleware and the bake the response
+            # if the response can be baked
+            if hasattr(response, 'bake') and callable(response.bake):

The first line of the comment should be "and the*n* bake the response".

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

Reply via email to