template: refactor template.ezt lookup (#7209)

This commit is contained in:
Frédéric Péters 2015-05-12 10:13:20 +02:00
parent 94868cd068
commit f03781948a
1 changed files with 14 additions and 15 deletions

View File

@ -363,22 +363,21 @@ def decorate(body, response):
possible_filenames.append('template.%s.ezt' % get_publisher().APP_NAME)
possible_filenames.append('template.ezt')
possible_dirnames = [
os.path.join(get_publisher().app_dir, 'themes', current_theme),
os.path.join(get_publisher().data_dir, 'themes', current_theme),
os.path.join(get_publisher().data_dir, 'themes', 'default'),
]
for fname in possible_filenames:
filename = os.path.join(get_publisher().app_dir, 'themes',
current_theme, fname)
if os.path.exists(filename):
template_ezt = file(filename).read()
break
filename = os.path.join(get_publisher().data_dir, 'themes',
current_theme, fname)
if os.path.exists(filename):
template_ezt = file(filename).read()
break
filename = os.path.join(get_publisher().data_dir, 'themes',
'default', fname)
if os.path.exists(filename):
template_ezt = file(filename).read()
break
for dname in possible_dirnames:
filename = os.path.join(dname, fname)
if os.path.exists(filename):
template_ezt = file(filename).read()
break
else:
continue
break
if template_ezt:
generate_breadcrumb = ('[breadcrumb]' in template_ezt)