On Feb 20, 2009, at 20:38, Ben Gerdemann wrote:
>
> I just spent a good part of my afternoon tracking down a bug in my
> code, that eventually turned out to be a Unicode encoding problem. The
> reason it took me so long to track down the problem is this code here
> in 'template/__init__.py':
>
> 794 class VariableNode(Node):
> ...
> 801 def render(self, context):
> 802 try:
> 803 output = force_unicode(self.filter_expression.resolve
> (context))
> 804 except UnicodeDecodeError:
> 805 # Unicode conversion can fail sometimes for reasons
> out of our
> 806 # control (e.g. exception rendering). In that case,
> we fail quietly.
> 807 return ''
>
> Is there a good reason that the widget rendering is silently capturing
> all Unicode errors? Now that I know that it's doing this, it won't
> take me so long to figure out the problem if it happens again, but it
> certainly wasn't expected behavior. At the very least, maybe we could
> return 'UnicodeDecodeError' instead of a blank string?
I think this is a symptom of a much greater issue: the templating
system *silences* errors a lot. I think there should be some logging
mechanism (possibly using Python's logging module?) that logs errors
in templates.
I for one would *love* this, so instead::
logger = logging.getLogger("django.template")
# ...
try:
do_whatever()
except MyError:
logger.
I mean, they're errors, but the reason they're silenced is that the
show often must go on. Not that an error condition is impossible.
- Ludvig
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django developers" 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-developers?hl=en
-~----------~----~----~----~------~----~------~--~---