On 10/21/2010 03:22 PM, Ivan Sagalaev wrote:
On 10/21/2010 11:49 AM, Mikhail Korobov wrote:
2. Does TemplateResponse allow pretty exception pages or not? Is Ben's
issue resolved?

I'll look into it this evening (MSD).

So I did.

There are actually two problems:

- Exceptions in response middleware are indeed happen outside of the request's `try .. except` block. This is a problem by itself[1] and I'd be happy to fix it after ticket 9886[2] is committed. It's another refactoring of core request code so I don't want to mess things up doing one patch on top of another :-).

- Non-pretty plain text tracebacks can be caused not only be middleware but also by any error occurring during template rendering. Because all this happen *after* request was returned to the web server handler and is being iterated over.

This second problem can be easily fixed by introducing a method for explicit evaluation of the content: `evaluate()` or `force_content()` that will be a noop for any HttpRespone class except the TemplateResponse. The method will be called by the request handler right before returning the response.

Sounds good?

P.S. BTW looking at the TemplateResponse implementation I see that Simon had actually intended it to be effectively *the* render shortcut[3]. I find it quite beautiful really :-)

[1]: http://code.djangoproject.com/ticket/14523
[2]: http://code.djangoproject.com/ticket/9886
[3]: http://github.com/simonw/django-openid/blob/master/django_openid/response.py#L85

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