[ZPT] CVS: Zope/lib/python/Products/PageTemplates - Expressions.py:1.32.2.3

Florent Guillaume fg@nuxeo.com
Fri, 15 Mar 2002 15:34:52 +0000 (UTC)


> Modified Files:
>       Tag: shane-better-tracebacks-branch
> 	Expressions.py 
> Log Message:
> Catch only specific TypeErrors.  Added XXX comments--I hope Python 2.2 can
> rescue us from this messy exception handling.  There's no way to know
> whether an object supports the item interface without calling it.
>[...]
> +                except TypeError, exc:
> +                    if str(exc).find('unsubscriptable') >= 0:
> +                        # The object does not support the item interface.
> +                        # Try to re-raise the original attribute error.
> +                        # XXX This is sooooo ugly.
> +                        get(object, name)
>                      raise

Besides, won't this fail if and when internationalization of python
comes into play ?


Florent

-- 
Florent Guillaume, Nuxeo (Paris, France)
+33 1 40 33 79 10  http://nuxeo.com  mailto:fg@nuxeo.com