Doesn't seem too likely to me as all user-facing rendering functions would 
have to accept (require?) the request argument.

By the way, not sure if this post might have been meant for the 
django-developers mailing list?

On Monday, June 6, 2016 at 6:02:26 AM UTC-4, aRkadeFR wrote:
>
>
> Hello all, 
>
> I'd like to open a discussion on the Loader Template 
> (django/template/loaders/app_directories.py) 
> which is linked to the Template Engine (django/template/engine.py) about 
> the context it has when determining the templates to load. 
>
> ## Use Case 
>
> In order to do multi-tenancy on our project, we set the current_site on 
> the input request in a middleware (almost the same as 
> django/contrib/sites/middleware.py). 
>
> Then our part of the system base its computation on the current_site of 
> the request. 
>
> Some of our clients needs to have specific markup template (.html 
> template). 
>
> In order to do that, we chose a hierarchy of templates, that can be 
> overriden if we have another folder with the same name of the 
> client/website. 
>
> Let's take an example: 
>
> We have as templates: 
> - /default/base.html 
> - /custom/base.html 
>
> If the request.site is named "custom", then we want to load the 
> /custom/base.html . Otherwise we load the /default/base.html 
>
>
> ## Problem encounter 
>
> The Loader for the template doesn't have any context, and so we have 
> setup a global state with the request in threads local. I personnaly 
> hate global state in Django 
> (https://code.djangoproject.com/wiki/GlobalState). 
>
>
> ## Proposal 
>
> I'd like to know if we could add the possibility to have more context on 
> the Loader? At least the request? 
>
> This is a bit of refacto in the code of Django as the Engine is created 
> only once for every Django process. 
>
>
> Thanks for your reading, 
>
> Have a good day 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3b45ff91-07c2-4350-8b40-ab7652e18dc9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to