summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Kaplan-Moss <jacob@jacobian.org>2007-02-06 13:59:24 +0000
committerJacob Kaplan-Moss <jacob@jacobian.org>2007-02-06 13:59:24 +0000
commitb5f91761152685f8c7f6bed9dca3d0742532dffc (patch)
treeed6a9a8bada9b76f6ea0d57e3f034b742a45967e
parent04c4a031ba61abb88996f785d188b25113fb62dd (diff)
Fixed #3441: VariableDoesNotExist is now a bit lazier about rendering its error message. Thanks, Brian Harring.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@4461 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/template/__init__.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/django/template/__init__.py b/django/template/__init__.py
index 7718801684..608055213f 100644
--- a/django/template/__init__.py
+++ b/django/template/__init__.py
@@ -117,8 +117,14 @@ class TemplateDoesNotExist(Exception):
pass
class VariableDoesNotExist(Exception):
- pass
+ def __init__(self, msg, params=()):
+ self.msg = msg
+ self.params = params
+
+ def __str__(self):
+ return self.mgs % self.params
+
class InvalidTemplateLibrary(Exception):
pass
@@ -660,7 +666,7 @@ def resolve_variable(path, context):
try: # list-index lookup
current = current[int(bits[0])]
except (IndexError, ValueError, KeyError):
- raise VariableDoesNotExist, "Failed lookup for key [%s] in %r" % (bits[0], current) # missing attribute
+ raise VariableDoesNotExist("Failed lookup for key [%s] in %r", (bits[0], current)) # missing attribute
except Exception, e:
if getattr(e, 'silent_variable_failure', False):
current = settings.TEMPLATE_STRING_IF_INVALID