[Zope-Coders] Re: [Zope.Com Geeks] No Zope tracebacks
Barry A. Warsaw
barry@zope.com
Mon, 20 May 2002 15:28:22 -0400
>>>>> "GvR" == Guido van Rossum <guido@python.org> writes:
GvR> I am trying the ZMI with some new code on the Zope 2 trunk,
GvR> and I need tracebacks. When I get an error, the message
GvR> For more detailed information about the error, please refer
GvR> to the HTML source for this page.
GvR> is displayed, but there is no traceback in the HTML source.
GvR> (I've looked in all frames!)
GvR> I showed this to Jim last week and he was very surprised.
GvR> Did something break? Can anyone help me with this? I have
GvR> no idea where to start looking.
Guido, I recently hit the exact same problem with the Zope2 trunk.
I've no clue why tracebacks aren't happening now, and I distinctly
remember that they were at one point. I did a bunch of googling and
zope.org searching and didn't come up with much. Then I searched my
mail folders. :)
I found an internal message from Chris McDonough dated Aug 2001 which
gave me a clue, although it required hacking the Zope source. I
modified his suggestion a bit and came up with the following, which
doesn't actually give me the traceback in an html comment, but does
give me a traceback on stdout (as Chris's suggestion did). That was
good enough for my purposes, so I stopped there.
Below is the patch I threw together. I'd be interested in a more
principled way of doing this.
-Barry
Index: lib/python/Zope/__init__.py
===================================================================
RCS file: /cvs-repository/Zope/lib/python/Zope/__init__.py,v
retrieving revision 1.29
diff -u -r1.29 __init__.py
--- lib/python/Zope/__init__.py 7 Feb 2002 18:16:02 -0000 1.29
+++ lib/python/Zope/__init__.py 20 May 2002 19:24:55 -0000
@@ -102,6 +102,11 @@
ConflictError=ZODB.POSException.ConflictError,
ListType=type([]),
):
+ from zLOG.FormatException import format_exception
+ x = format_exception(t, v, traceback)
+ for line in x:
+ print line[:-1]
+
try:
if isinstance(t, StringType):
if t.lower() in ('unauthorized', 'redirect'):