It seems, that Django handles methods and variables indexes differently.
So I solved it this way:
e = IndexError()
e.silent_variable_failure = True
raise e
Martin
On Wed, 21 Sep 2011 23:36:58 +0200, Martin Tiršel <dja...@blackpage.eu>
wrote:
Hello,
I have this situation:
class SomeClass(object):
...
def __getitem__(self, key):
...
raise IndexError()
and now:
context['somevar'] = {'one': 1, }
context['anothervar'] = SomeClass()
in template:
{{ somevar.one }} - prints 1
{{ somevar.two }} - prints nothing, no exception raised
{{ anothervar.notexistentindex }} - raises IndexError and page doesn't
load (debug info printed)
Does anybody knows why? In both cases IndexError exception is raised but
first case doesn't stop page loading, the another stops and prints debug
info. I need silent ignore. What is the difference between "native"
IndexError and my IndexError?
Thanks,
Martin
--
You received this message because you are subscribed to the Google Groups "Django
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.