Author: kmtracey
Date: 2010-03-22 14:08:04 -0500 (Mon, 22 Mar 2010)
New Revision: 12834
Modified:
django/trunk/django/template/__init__.py
django/trunk/tests/regressiontests/templates/tests.py
Log:
Fixed #12554 again: Corrected regression in silencing attribute lookups
introduced in r12823, plus added a test for this so it doesn't regress again.
Modified: django/trunk/django/template/__init__.py
===================================================================
--- django/trunk/django/template/__init__.py 2010-03-22 13:29:26 UTC (rev
12833)
+++ django/trunk/django/template/__init__.py 2010-03-22 19:08:04 UTC (rev
12834)
@@ -745,6 +745,11 @@
TypeError, # unsubscriptable object
):
raise VariableDoesNotExist("Failed lookup for key [%s]
in %r", (bit, current)) # missing attribute
+ except Exception, e:
+ if getattr(e, 'silent_variable_failure', False):
+ current = settings.TEMPLATE_STRING_IF_INVALID
+ else:
+ raise
except Exception, e:
if getattr(e, 'silent_variable_failure', False):
current = settings.TEMPLATE_STRING_IF_INVALID
Modified: django/trunk/tests/regressiontests/templates/tests.py
===================================================================
--- django/trunk/tests/regressiontests/templates/tests.py 2010-03-22
13:29:26 UTC (rev 12833)
+++ django/trunk/tests/regressiontests/templates/tests.py 2010-03-22
19:08:04 UTC (rev 12834)
@@ -101,6 +101,11 @@
def __getitem__(self, key):
raise SomeException
+class SilentAttrClass(object):
+ def b(self):
+ raise SomeException
+ b = property(b)
+
class UTF8Class:
"Class whose __str__ returns non-ASCII data"
def __str__(self):
@@ -471,8 +476,9 @@
# regression test for ticket #12554
# make sure a silent_variable_failure Exception is supressed
- # on dictionary lookup
+ # on dictionary and attribute lookup
'basic-syntax28': ("{{ a.b }}", {'a': SilentGetItemClass()}, ('',
'INVALID')),
+ 'basic-syntax29': ("{{ a.b }}", {'a': SilentAttrClass()}, ('',
'INVALID')),
# List-index syntax allows a template to access a certain item of
a subscriptable object.
'list-index01': ("{{ var.1 }}", {"var": ["first item", "second
item"]}, "second item"),
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.