diff options
| author | Robin Munn <robin.munn@gmail.com> | 2006-09-05 15:51:14 +0000 |
|---|---|---|
| committer | Robin Munn <robin.munn@gmail.com> | 2006-09-05 15:51:14 +0000 |
| commit | 70e05817910d5fe757a3a235252ef7c12e058676 (patch) | |
| tree | 98583716fe36100c8b9e82e31325993d3b4f382b /django/template/__init__.py | |
| parent | 083ebb346844ece29d81bacdd5ec6574feae3896 (diff) | |
sqlalchemy: Merged revisions 3679 to 3723 from trunk.
git-svn-id: http://code.djangoproject.com/svn/django/branches/sqlalchemy@3724 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/template/__init__.py')
| -rw-r--r-- | django/template/__init__.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/django/template/__init__.py b/django/template/__init__.py index ba7ca4c02b..fa75f6c2f5 100644 --- a/django/template/__init__.py +++ b/django/template/__init__.py @@ -137,13 +137,14 @@ class StringOrigin(Origin): return self.source class Template(object): - def __init__(self, template_string, origin=None): + def __init__(self, template_string, origin=None, name='<Unknown Template>'): "Compilation stage" if settings.TEMPLATE_DEBUG and origin == None: origin = StringOrigin(template_string) # Could do some crazy stack-frame stuff to record where this string # came from... self.nodelist = compile_string(template_string, origin) + self.name = name def __iter__(self): for node in self.nodelist: @@ -434,7 +435,7 @@ class TokenParser(object): while i < len(subject) and subject[i] != subject[p]: i += 1 if i >= len(subject): - raise TemplateSyntaxError, "Searching for value. Unexpected end of string in column %d: %s" % subject + raise TemplateSyntaxError, "Searching for value. Unexpected end of string in column %d: %s" % (i, subject) i += 1 res = subject[p:i] while i < len(subject) and subject[i] in (' ', '\t'): @@ -548,9 +549,12 @@ class FilterExpression(object): obj = resolve_variable(self.var, context) except VariableDoesNotExist: if ignore_failures: - return None + obj = None else: - return settings.TEMPLATE_STRING_IF_INVALID + if settings.TEMPLATE_STRING_IF_INVALID: + return settings.TEMPLATE_STRING_IF_INVALID + else: + obj = settings.TEMPLATE_STRING_IF_INVALID for func, args in self.filters: arg_vals = [] for lookup, arg in args: @@ -614,11 +618,7 @@ def resolve_variable(path, context): (The example assumes VARIABLE_ATTRIBUTE_SEPARATOR is '.') """ - if path == 'False': - current = False - elif path == 'True': - current = True - elif path[0].isdigit(): + if path[0].isdigit(): number_type = '.' in path and float or int try: current = number_type(path) |
