Am 16.11.2009 um 15:31 schrieb Russell Keith-Magee:
> On Mon, Nov 16, 2009 at 10:04 PM, Alex Gaynor
> <[email protected]> wrote:
>> On Mon, Nov 16, 2009 at 8:58 AM, Russell Keith-Magee
>> <[email protected]> wrote:
>>> On Thu, Nov 12, 2009 at 9:15 AM, Mike Malone <[email protected]>
>>> wrote:
>>>> Sup,
>>>>
>>>> I've been working on template caching (ticket #6262) with a mister
>>>> Alex Gaynor. The patch is getting pretty stable and I think it's
>>>> close
>>>> to merge-able, so if anyone wants to take a look at what we've
>>>> got and
>>>> provide feedback: go!
> ...
>>> * On the subject of specifying loaders - in order to use the cached
>>> loader, we need to import the cached loader, and have support for
>>> callable loaders in find_template_loader. Requiring imports in the
>>> settings file seems like a bit of a wart to me.
>>>
>>> Here's an alternate proposal - rather than allowing callables, how
>>> about allowing entries in TEMPLATE_LADERS to be tuples, and
>>> interpreting the [1:] elements of the tuple as the arguments to the
>>> loader - for example:
>>>
>>> TEMPLATE_LOADERS = (
>>> ('django.template.loaders.cached', (
>>> 'django.template.loaders.filesystem.loader',
>>> 'django.template.loaders.app_directories.loader',
>>> )
>>> )
>>> )
>>>
>> I think this could get fairly complicated quickly, for example is
>> this valid?
>>
>> TEMPLATE_LOADERS = (
>> ('django.templaet.loaders.cached', (
>> ('django.template.loaders.filesystem', (
>> '/home/alex/django/templates/',
>> )
>> )
>> )
>
> Sure. Why not? The intention of what you have written seems pretty
> clear to me (typo and missing brackets notwithstanding :-).
Couldn't you just make this explicit (and more readable)?
{{{
# settings.py
TEMPLATE_LOADERS = ('project.template_loaders.loader',)
}}}
{{{
# template_loaders.py
from django.template.loaders.cached import Loader as CachingLoader
from django.template.loaders.filesystem import Loader as
FileSystemLoader
loader = CachingLoader([
FileSystemLoader([
'/path/to/templates',
]),
])
}}}
If I read the patch correctly, that should already be possible and
solves arbitrarily complex initialization for loaders.
If there has to be a convenience addition, how about a simple boolean
`WRAP_TEMPLATE_LOADERS_WITH_CACHING_LOADER=True#FIXME: find a better
name`?
__
Johannes
--
You received this message because you are subscribed to the Google Groups
"Django developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-developers?hl=.