Fixed #505 -- ssi template tag now displays a message instead of failing silently if DEBUG=True. Thanks, Manuzhai
git-svn-id: http://code.djangoproject.com/svn/django/trunk@1037 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
7136eb8f3a
commit
cee6faf43e
|
@ -211,8 +211,12 @@ class SsiNode(Node):
|
||||||
self.filepath, self.parsed = filepath, parsed
|
self.filepath, self.parsed = filepath, parsed
|
||||||
|
|
||||||
def render(self, context):
|
def render(self, context):
|
||||||
|
from django.conf.settings import DEBUG
|
||||||
if not include_is_allowed(self.filepath):
|
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:
|
try:
|
||||||
fp = open(self.filepath, 'r')
|
fp = open(self.filepath, 'r')
|
||||||
output = fp.read()
|
output = fp.read()
|
||||||
|
@ -223,8 +227,11 @@ class SsiNode(Node):
|
||||||
try:
|
try:
|
||||||
t = Template(output)
|
t = Template(output)
|
||||||
return t.render(context)
|
return t.render(context)
|
||||||
except TemplateSyntaxError:
|
except (TemplateSyntaxError, e):
|
||||||
return '' # Fail silently for invalid included templates.
|
if DEBUG:
|
||||||
|
return "[Included template had syntax error: %s]" % e
|
||||||
|
else:
|
||||||
|
return '' # Fail silently for invalid included templates.
|
||||||
return output
|
return output
|
||||||
|
|
||||||
class LoadNode(Node):
|
class LoadNode(Node):
|
||||||
|
|
Loading…
Reference in New Issue