Re: Proposal: Add current_app to request and pass it to template loaders.

2011-03-10 Thread Doug Ballance
I too would very much like a request aware template loader.  For my
project the threadlocals approach was the only way I could find to
meet my requirements of a site-based template structure (project has
multitenancy) and user selectable template 'themes'.

I've tried looking at the django source to come up with a non-
threadlocals implementation, but came to the conclusion that it wasn't
easily possible without some kind of global due to the way the
templates are compiled.

Some tags you could potentially add 'hidden' values like __theme__ in
the context using RequestContext and then have the tags pass those on
to get_template(). Assuming tags played nicely and always passed along
those values to their nodelists contexts.

Other tags like {% include "app/sometemplate.html"%} get the template
at compile time of the parent template.  The compiled template might
be cached, or otherwise re-used - so that approach isn't reliable.

I hope there is a solution I overlooked.



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



Re: TemplateResponse and loader should handle request

2011-11-09 Thread Doug Ballance
I very much like the idea of an optional keyword argument and
fallback.  The template loader is one of the few places I've been
forced to use threadlocals to get get the job done.

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