2010/10/29 Mikhail Korobov <kmik...@googlemail.com>: > Hi Russel, > > Thank you for your reviews and moving things on! > > On 29 окт, 07:35, Russell Keith-Magee <russ...@keith-magee.com> wrote: >> >> I like this idea -- it's is an elegant solution to the problem, and >> avoids all the backwards compatibility issues I can think of. >> >> I have two comments: >> >> Firstly, there needs to be a shortcut for non-template responses. If >> your response isn't a template response, there's no point putting it >> through Template Reponse Middleware. >> > > Ivan's code doesn't put non-template responses through template > response middleware. Whenever the response is a template response is > determined by the presence of 'force_bake' method.
Ah - I wasn't aware there was a working implementation of this idea -- did I miss a link somewhere? >> Secondly, it seems to me like there may be some need for baking >> protection here. If any template-response-middleware were to bake the >> response, subsequent template-reposnse-middlewares could potentially >> have problems, as any changes they make to context etc will be >> ignored. Wouldn't it make sense to put a flag on the TemplateResponse >> that prohibits accidental baking? That way the force_bake() that >> happens between the template-response-middleware and the normal >> response-middleware would be the guaranteed point at which the >> template is writ large as content. >> > > As I can see, users shouldn't bake responses not only in middlewares. > They shouldn't bake responses anywhere in their code. > > The original TemplateResponse idea was not the same. Agreed. This is a change from the original completely-lazy-evaluated TemplateResponse idea, but I think it makes sense in terms of being explicit and avoiding a wealth of potential bugs in implicit evaluation. > So maybe it will be better not to make bake/force_bake public so that > users won't be able to shoot themselves in the foot? And maybe it'll > be better even not to bake response magically on first content > access? That's essentially what I was suggesting -- that if a middleware or decorator accidental accessed response.content before the end of template-context-processor handling (when the explicit baking occurs), it should raise an exception rather than implicitly baking the response. 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.