Skip to content

Commit

Permalink
Adapt render_snippet exceptions for py3
Browse files Browse the repository at this point in the history
  • Loading branch information
smotornyuk committed Jan 23, 2020
1 parent 6257297 commit dba1f98
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions ckan/lib/base.py
Expand Up @@ -88,7 +88,7 @@ def render_snippet(*template_names, **kw):
:type kw: named arguments of any type that are supported by the template
'''

exc = None
last_exc = None
for template_name in template_names:
try:
output = render(template_name, extra_vars=kw)
Expand All @@ -99,7 +99,10 @@ def render_snippet(*template_names, **kw):
return h.literal(output)
except TemplateNotFound as exc:
if exc.name == template_name:
# the specified template doesn't exist - try the next fallback
# the specified template doesn't exist - try the next
# fallback, but store the exception in case it was
# last one
last_exc = exc
continue
# a nested template doesn't exist - don't fallback
raise exc
Expand Down

0 comments on commit dba1f98

Please sign in to comment.