On Fri, Oct 22, 2010 at 12:34 AM, Ivan Sagalaev
<man...@softwaremaniacs.org> wrote:
> 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?

Hi Ivan and Mikhail,

Just so you don't get the feeling that you're just discussing this
between yourselves -- I'm historically on record of being in favor of
the render() shortcut and the TemplateResponse(), and my position
hasn't changed recently.  This is exactly the sort of problem that I
want to target for 1.3 (especially since we're now tracking 6 closely
related tickets -- #9081, #9886, #12815, #12816, #12669 and #14523 --
making this a sweet spot for attention).

Jacob has already marked #9886 RFC, and on first inspection, the patch
looks good to me too; I want to have a closer look before I commit,
though. If you want to proceed assuming that #9886 will be committed
(i.e., make the fix for #14523 have #9866 as a prerequisite), I doubt
it would be wasted effort.

Regarding the second problem you describe -- unless I'm mistaken,
Simon's TemplateResponse addresses this with his "baking" concept; a
response is baked the first time it is iterated or otherwise
evaluated.

I have a couple of non-Django things to attend to over the next week
or so; but once those are sorted out, I should be able to take a
detailed look at any patches you have prepared.

Yours,
Russ Magee %-)

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