On Mon, 2006-10-23 at 09:10 +0000, Le Roux Bodenstein wrote:
> I'm trying to do some form of skinning with Django's templating engine.
> Without going into too much detail, my project is kindof a service that
> powers multiple sites. Each site can have a skin inside a site-specific
> folder. These folders are not parallel to each other.
> 
> for example:
> 
> myapp/webroot/media/domainone.com/myskin/
> myapp/webroot/media/domaintwo.com/otherskin/
> 
> These folders contain templates. I want to be able to (at runtime)
> specify this folder to the template engine. This means adding them all
> to TEMPLATE_DIRS is a definite no. I was looking at the documentation
> and the code and it doesn't look like this will work. Workarounds like
> specifying a long path as the template name
> (folder/subfolder/someotherfolder/template.html) will not work, because
> these sites should not be able to access each other's templates.
> 
> The main things I am looking for are.. Can I load the template from an
> arbitrary folder? Will extends work correctly and load the template
> we're inheriting from from that same folder?

There aren't enough details to answer these questions specifically,
although I strongly suspect the answer is "yes" for any reasonable set
of requirements. You get a lot of flexibility with template loaders.

[...]
> Basically, from what I can tell, the Django template engine is very
> (probably too) tightly tied to the settings module and the little bits
> that imply otherwise are a misleading.

I think you'll find this isn't the case. The default template loaders
(it's not really accurate to talk about the "template engine", since
that's not a well-defined thing -- do you mean a specific loader, or the
thing that renders the templates, or ...) take their settings from the
settings module, which isn't at all unreasonable, since it provides
consistent behaviour and configuration in one place.

If you want more flexibility, Django provides a way to do that by
default too, since you can specify the template loader(s) you want to
use.

> Please correct me if I'm wrong about this. Has anyone else thought
> about it? Does anyone have ideas on how to fix it or at least work
> around it?

This can be solved by writing your own template loader that takes its
particular runtime configuration from wherever you like? Template
loaders are very simple to write -- maybe a dozen lines of code,
typically. Then you just tell Django to use your template loader, rather
than one of the three that ship with it. It's up to your loader whether
you want to pay attention to the "dirs" argument or not. You will need
to come up with some way of telling your loader which directories to
look in, but that's a problem you have in any scheme like the one you
propose with runtime-specific configuration like that. It all sounds
completely solvable, though, without needing to alter any Django source.

Regards,
Malcolm


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers
-~----------~----~----~----~------~----~------~--~---

Reply via email to