summaryrefslogtreecommitdiff
path: root/docs/templates_python.txt
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2005-12-16 01:58:03 +0000
committerAdrian Holovaty <adrian@holovaty.com>2005-12-16 01:58:03 +0000
commit58f61e03731a3f948e931cd1c1749c250114dc4b (patch)
tree7d902bfae45ec6e7a9a164dea6e134b2bf82d7fe /docs/templates_python.txt
parente4fb3982a1c50f723bb5f9da55567f26cae351e2 (diff)
magic-removal: Removed SilentVariableFailure exception, in favor of a silent_variable_failure attribute on the exception. Updated docs and added unit tests.
git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@1680 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/templates_python.txt')
-rw-r--r--docs/templates_python.txt20
1 files changed, 13 insertions, 7 deletions
diff --git a/docs/templates_python.txt b/docs/templates_python.txt
index de212cd141..3bedf67caa 100644
--- a/docs/templates_python.txt
+++ b/docs/templates_python.txt
@@ -147,10 +147,10 @@ Method lookups are slightly more complex than the other lookup types. Here are
some things to keep in mind:
* If, during the method lookup, a method raises an exception, the exception
- will be propagated, unless the exception subclasses
- ``django.core.template.SilentVariableFailure``. If the exception
- subclasses ``SilentVariableFailure``, the variable will render as an
- empty string. Example::
+ will be propagated, unless the exception has an attribute
+ ``silent_variable_failure`` whose value is ``True``. If the exception
+ *does* have a ``silent_variable_failure`` attribute, the variable will
+ render as an empty string. Example::
>>> t = Template("My name is {{ person.first_name }}.")
>>> class PersonClass3:
@@ -162,15 +162,21 @@ some things to keep in mind:
...
AssertionError: foo
- >>> from django.core.template import SilentVariableFailure
- >>> class SilentAssertionError(SilentVariableFailure): pass
+ >>> class SilentAssertionError(Exception):
+ ... silent_variable_failure = True
>>> class PersonClass4:
... def first_name(self):
- ... raise SilentAssertionError, "foo"
+ ... raise SilentAssertionError
>>> p = PersonClass4()
>>> t.render(Context({"person": p}))
"My name is ."
+ Note that ``django.core.exceptions.ObjectDoesNotExist``, which is the
+ base class for all Django database API ``DoesNotExist`` exceptions, has
+ ``silent_variable_failure = True``. So if you're using Django templates
+ with Django model objects, any ``DoesNotExist`` exception will fail
+ silently.
+
* A method call will only work if the method has no required arguments.
Otherwise, the system will move to the next lookup type (list-index
lookup).