To all using xmlrpclib,

I had trouble getting a proper display of my exceptions occuring on the server. Basically, xmlrpclib only display the exception itself without any traceback, on the client side.

Something like
<Fault 1: "<type 'exceptions.KeyError'>:2">

Ok then there's a key error, but how the hell am I supposed to know where it occured ?

So I wrote this:
from SimpleXMLRPCServer import SimpleXMLRPCServer
server = SimpleXMLRPCServer(('localhost', 8000), logRequests=False, allow_none=True)
old_dispatch = server._dispatch
def _new_dispatch(method, params):
   try:
       return old_dispatch(method,params)
   except Exception, exc:
       import traceback
       traceback.print_exc()
       raise
server._dispatch = _new_dispatch


Pretty dirty, isn't it, accessing the private attributes (too lazy to subclass) ! I guess there's an obvious way to do this with xmlrpclib that I just missed. Anyone knows ?

JM
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to