I have found two solutions
################################
Method 1:
Write a custom template filter that calls resolve_variable, and thus
raise an exception if {{var.arg}} fails. This will not catch the case
where var is not part of the template context {{var}}
The filter function is
-----------------------------
register = webapp.template.create_template_register()
@register.filter
def resolve(value, arg):
"""resolve the lookup of arg in value, raise exception if not found"""
return resolve_variable('var.' + arg, {'var' : value})
-----------------------------
In the template use, instead of {{var.arg}}
{{var|resolve:"arg"}}
################################
Method 2:
Monkey patch the FilterExpression.resolve() method. Replace it with a
working version.
Add the following code to your request handler .py file
-----------------------------
from google.appengine.ext.webapp import template
import django.template
from django.template import resolve_variable,VariableDoesNotExist
from django.conf import settings
##class FilterExpression(object):
## from django.template
def resolve(self, context, ignore_failures=False):
try:
obj = resolve_variable(self.var, context)
except VariableDoesNotExist:
if ignore_failures:
if settings.TEMPLATE_STRING_IF_INVALID:
return settings.TEMPLATE_STRING_IF_INVALID
else:
obj = settings.TEMPLATE_STRING_IF_INVALID
else:
# simplify the stackdump
if isinstance(e.params[1],django.template.context.Context):
raise VariableDoesNotExist(e.msg,(e.params[0],"Main context"))
raise
for func, args in self.filters:
arg_vals = []
for lookup, arg in args:
if not lookup:
arg_vals.append(arg)
else:
arg_vals.append(resolve_variable(arg, context))
obj = func(obj, *arg_vals)
return obj
django.template.FilterExpression.resolve = resolve
-----------------------------
In the template: {{var.notthere}} will raise an exception, with only
"var" in the context.
And {{notthere}} will print an exception without context dump.
2010/7/11 Webb S. <webb.s...@gmail.com>:
> --
> You received this message because you are subscribed to the Google Groups "Google App Engine" group.
> To post to this group, send email to google-a...@googlegroups.com.
> To unsubscribe from this group, send email to google-appengi...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.
>
>