Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
  • Loading branch information...
commit b5f91761152685f8c7f6bed9dca3d0742532dffc 1 parent 04c4a03
Jacob Kaplan-Moss authored February 06, 2007

Showing 1 changed file with 8 additions and 2 deletions. Show diff stats Hide diff stats

  1. 10  django/template/__init__.py
10  django/template/__init__.py
@@ -117,8 +117,14 @@ class TemplateDoesNotExist(Exception):
117 117
     pass
118 118
 
119 119
 class VariableDoesNotExist(Exception):
120  
-    pass
121 120
 
  121
+    def __init__(self, msg, params=()):
  122
+        self.msg = msg
  123
+        self.params = params
  124
+    
  125
+    def __str__(self):
  126
+        return self.mgs % self.params
  127
+    
122 128
 class InvalidTemplateLibrary(Exception):
123 129
     pass
124 130
 
@@ -660,7 +666,7 @@ def resolve_variable(path, context):
660 666
                     try: # list-index lookup
661 667
                         current = current[int(bits[0])]
662 668
                     except (IndexError, ValueError, KeyError):
663  
-                        raise VariableDoesNotExist, "Failed lookup for key [%s] in %r" % (bits[0], current) # missing attribute
  669
+                        raise VariableDoesNotExist("Failed lookup for key [%s] in %r", (bits[0], current)) # missing attribute
664 670
                 except Exception, e:
665 671
                     if getattr(e, 'silent_variable_failure', False):
666 672
                         current = settings.TEMPLATE_STRING_IF_INVALID

0 notes on commit b5f9176

Please sign in to comment.
Something went wrong with that request. Please try again.