Skip to content

Commit

Permalink
Fixed #505 -- ssi template tag now displays a message instead of fail…
Browse files Browse the repository at this point in the history
…ing silently if DEBUG=True. Thanks, Manuzhai

git-svn-id: http://code.djangoproject.com/svn/django/trunk@1037 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
adrianholovaty committed Nov 1, 2005
1 parent 7136eb8 commit cee6faf
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions django/core/template/defaulttags.py
Expand Up @@ -211,8 +211,12 @@ def __init__(self, filepath, parsed):
self.filepath, self.parsed = filepath, parsed

def render(self, context):
from django.conf.settings import DEBUG
if not include_is_allowed(self.filepath):
return '' # Fail silently for invalid includes.
if DEBUG:
return "[Didn't have permission to include file]"
else:
return '' # Fail silently for invalid includes.
try:
fp = open(self.filepath, 'r')
output = fp.read()
Expand All @@ -223,8 +227,11 @@ def render(self, context):
try:
t = Template(output)
return t.render(context)
except TemplateSyntaxError:
return '' # Fail silently for invalid included templates.
except (TemplateSyntaxError, e):
if DEBUG:
return "[Included template had syntax error: %s]" % e
else:
return '' # Fail silently for invalid included templates.
return output

class LoadNode(Node):
Expand Down

0 comments on commit cee6faf

Please sign in to comment.