Fixed #21460 -- Reenabled proper template precedence in find_template

Refs #20806. Thanks Unai Zalakain for the review.
This commit is contained in:
Pablo Martín 2013-11-19 17:49:16 +01:00 committed by Claude Paroz
parent d6cc37d601
commit 3ac823fc5b
5 changed files with 34 additions and 0 deletions

View File

@ -420,6 +420,7 @@ answer newbie questions, and generally made Django that much better:
mark@junklight.com
Orestis Markou <orestis@orestis.gr>
Andrés Torres Marroquín <andres.torres.marroquin@gmail.com>
Pablo Martín <goinnn@gmail.com>
Takashi Matsuo <matsuo.takashi@gmail.com>
Zlatko Mašek <zlatko.masek@gmail.com>
Yasushi Masuda <whosaysni@gmail.com>

View File

@ -53,6 +53,7 @@ class Loader(BaseLoader):
pass
else:
result = (template, make_origin(display_name, loader, name, dirs))
break
self.find_template_cache[key] = result
if result:
return result

View File

@ -0,0 +1 @@
no priority

View File

@ -189,3 +189,33 @@ class TemplateDirsOverrideTest(unittest.TestCase):
for dirs in self.dirs_iter:
template = loader.select_template(['test_dirs.html'], dirs=dirs)
self.assertEqual(template.render(Context({})), 'spam eggs\n')
@override_settings(
TEMPLATE_LOADERS=(
('django.template.loaders.cached.Loader', (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
)),
)
)
class PriorityCacheLoader(TestCase):
def test_basic(self):
"""
Check that the order of template loader works. Refs #21460.
"""
t1, name = loader.find_template('priority/foo.html')
self.assertEqual(t1.render(Context({})), 'priority\n')
@override_settings(
TEMPLATE_LOADERS=('django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',),
)
class PriorityLoader(TestCase):
def test_basic(self):
"""
Check that the order of template loader works. Refs #21460.
"""
t1, name = loader.find_template('priority/foo.html')
self.assertEqual(t1.render(Context({})), 'priority\n')

View File

@ -0,0 +1 @@
priority