On Fri, Oct 16, 2009 at 6:01 PM, Yuri Baburov <burc...@gmail.com> wrote: > > That means, > 1) perfect render_to_response should be lazy.
This isn't a new idea - Simon Willison has been proposing this general idea for a while. He's been talking specifically about making template rendering lazy, so you can use middleware or wrapper views to modify the template or the contents of the context that is used for rendering, right up until the response is served back to the user. There is some working code here: http://code.google.com/p/django-openid/source/browse/trunk/django_openid/response.py > Of course there's direct_to_template. Don't know how that happened > that it appeared instead of enhancing render_to_response... > Can be that no one knows why it has happened so? Easy - direct_to_response is a generic view, not a template utility. It's designed to be the simplest possible generic view - the view that renders a template with some interpreted context. The internal processing done by direct_to_response (evaluating callables, etc) is driven entirely by its intended use case - deployment in urls.py. The fact that it can be used as a substitute for render_to_response is mostly an accident of the intentionally simple contract for a view - that it accepts a request as it's first argument, and returns a response. As is regularly noted on django-users and in various books, you can easily write view functions that wrap generic views to do pre-processing on view arguments before passing those arguments to the generic view. Using direct_to_response as a replacement for render_to_response is really just the ultimate extension of this theory. > Well, generally, I use to think that everything related to "django > views in general" constantly lacks devs attention. > Like it's perfect since long time ago. Or it is just too boring topic, > or API stability contract tied their hands, or just everyone get used > to it... Part of the problem here is betrayed by your choice of phrase - that views are "lack(ing) devs attention". The core developers aren't here to do your bidding. We work on the issues that we see as important - recently, that means we've been busy trying to get features like model validation and multi-db support into trunk. Views might not be perfect, and they might be able to work better, but they _work_. If you disagree, then *you* need to solve it. Remember - Django is open source. We'll take submissions from anyone. You just need to demonstrate to us that your ideas are sound and your implementation is robust. 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-developers@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 -~----------~----~----~----~------~----~------~--~---