From shane at zope.com Tue Feb 3 18:04:23 2004 From: shane at zope.com (Shane Hathaway) Date: Sun Aug 10 17:05:20 2008 Subject: [ZPT-CVS] CVS: Zope/lib/python/Products/PageTemplates - TALES.py:1.38.2.3 Message-ID: <200402032304.i13N4N0T002747@cvs.zope.org> 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 'Names:
%s
' % (escape(s)) From shane at zope.com Tue Feb 3 18:04:42 2004 From: shane at zope.com (Shane Hathaway) Date: Sun Aug 10 17:05:20 2008 Subject: [ZPT-CVS] CVS: Zope/lib/python/Products/PageTemplates - TALES.py:1.39 Message-ID: <200402032304.i13N4gqY002793@cvs.zope.org> Update of /cvs-repository/Zope/lib/python/Products/PageTemplates In directory cvs.zope.org:/tmp/cvs-serv2774 Modified Files: TALES.py Log Message: Catch unauthorized binding errors when formatting an exception === Zope/lib/python/Products/PageTemplates/TALES.py 1.38 => 1.39 === --- Zope/lib/python/Products/PageTemplates/TALES.py:1.38 Wed May 14 17:55:14 2003 +++ Zope/lib/python/Products/PageTemplates/TALES.py Tue Feb 3 18:04:41 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('') @@ -270,12 +271,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 'Names:
%s
' % (escape(s))