[Zope-Checkins] CVS: Zope/lib/python/Products/PageTemplates - TALES.py:1.38.2.3

Shane Hathaway shane at zope.com
Tue Feb 3 18:04:23 EST 2004


Update of /cvs-repository/Zope/lib/python/Products/PageTemplates
In directory cvs.zope.org:/tmp/cvs-serv2728

Modified Files:
      Tag: Zope-2_7-branch
	TALES.py 
Log Message:
Catch unauthorized binding errors when formatting an exception


=== Zope/lib/python/Products/PageTemplates/TALES.py 1.38.2.2 => 1.38.2.3 ===
--- Zope/lib/python/Products/PageTemplates/TALES.py:1.38.2.2	Tue Dec  2 10:37:42 2003
+++ Zope/lib/python/Products/PageTemplates/TALES.py	Tue Feb  3 18:04:22 2004
@@ -22,6 +22,7 @@
 from MultiMapping import MultiMapping
 from DocumentTemplate.DT_Util import ustr
 from GlobalTranslationService import getGlobalTranslationService
+from zExceptions import Unauthorized
 
 StringType = type('')
 
@@ -273,12 +274,18 @@
 
     def getInfo(self, as_html=0):
         import pprint
+        from cgi import escape
         data = self.context.contexts.copy()
-        s = pprint.pformat(data)
+        try:
+            s = pprint.pformat(data)
+        except Unauthorized, e:
+            s = '   - %s: %s' % (getattr(e, '__class__', type(e)), e)
+            if as_html:
+                s = escape(s)
+            return s
         if not as_html:
             return '   - Names:\n      %s' % s.replace('\n', '\n      ')
         else:
-            from cgi import escape
             return '<b>Names:</b><pre>%s</pre>' % (escape(s))
 
 




More information about the Zope-Checkins mailing list