Definitely one possibility. I've heard threadlocals is unreliable, though. Is that correct?
Here's another option I'm considering.... Say thirdpartyview renders 'template.html'. I can write my own template.html that looks like so: {% extends 'template.html'|theme %} {% block someblock %} {{ block.super }} {% endblock %} {% block anotherblock %} {{ block.super }} {% endblock %} And then my theme filter (which will have to be autoloaded) pulls request.user out of the context, determines the user's theme, and returns 'themedir/template.html' or 'default/template.html' or whatever. For templates used in template tags, I can, similarly, use the following as the entire template content: {% include 'tagetemplate.html'|theme %} Very roundabout way to accomplish things, but doesn't require any monkey-patching. What do you guys think? On Oct 13, 3:10 pm, Михаил Лукин <mihail.lu...@googlemail.com> wrote: > Seems that any solution would be dirty, so why don't you set threadlocal > variable with request and monkey-patch template loader? > > > > On Tue, Oct 13, 2009 at 11:03 PM, Nan <ringe...@gmail.com> wrote: > > > The trouble is that I've got third-party apps that have their own > > views that don't include the template logic. > > > so in thirdpartymodule.views.py: > > > def thirdpartyview(request, vars): > > # Do lots of fancy processing > > return render_to_response('template.html', context) > > > In my project, I need a view that is essentially the same as > > thirdpartyview, but also has the template selection logic instead of > > the hardcoded template path -- and I need to do this for every view I > > use for every third party app I've installed. > > > It seems a) silly and b) unmaintainable to completely duplicate all > > the logic from all the views from all these apps just to > > programmatically change the template path. > > -- > regards, > Mihail --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---