[Zope] No stack trace returned on XMLRPC call
Dieter Maurer
dieter@handshake.de
Fri, 30 Aug 2002 18:49:08 +0200
--u5YEGRw+CC
Content-Type: text/plain; charset=us-ascii
Content-Description: message body text
Content-Transfer-Encoding: 7bit
Jay, Dylan writes:
> ... no stack trace in faulte XML-RPC responses ...
>
> Is this a bug, yes or no?
Strictly speaking, it is not a bug (because no one promisses this feature).
However, I started to work with XML-RPC recently and got annoyed by
the difficulty to analyse problems. I patched "ZPublisher.xmlrpc"
to send tracebacks with the response.
Patch attached.
Dieter
--u5YEGRw+CC
Content-Type: text/plain
Content-Description: ZPublisher.xmlrpc patch to include compact stack traces in fault responses
Content-Disposition: inline;
filename="xmlrpc.pat"
Content-Transfer-Encoding: 7bit
--- xmlrpc.py~ Wed Jan 9 18:51:57 2002
+++ xmlrpc.py Fri Aug 30 16:51:10 2002
@@ -122,15 +122,29 @@
# Create an appropriate Fault object. Unfortunately, we throw away
# most of the debugging information. More useful error reporting is
# left as an exercise for the reader.
+
+ # DM
+ # we include now a compact traceback, if possible
+ def _compactTb(tb):
+ '''return a compact traceback (or '').'''
+ if tb is None: return ''
+ info= []
+ while tb:
+ f= tb.tb_frame.f_code
+ info.append((f.co_filename,f.co_name,str(tb.tb_lineno)))
+ tb= tb.tb_next
+ return '|'.join(map(':'.join,info))
+ tb= tb and _compactTb(tb) or ''
+
Fault=xmlrpclib.Fault
f=None
try:
if isinstance(v, Fault):
f=v
elif isinstance(v, Exception):
- f=Fault(-1, "Unexpected Zope exception: " + str(v))
+ f=Fault(-1, "Unexpected Zope exception: %s: %s [%s]" % (str(t), str(v),tb))
else:
- f=Fault(-2, "Unexpected Zope error value: " + str(v))
+ f=Fault(-2, "Unexpected Zope error value: %s: %s [%s]" % (str(t),str(v),tb))
except:
f=Fault(-3, "Unknown Zope fault type")
--u5YEGRw+CC--