Python Desktop Server Weblog 13.2.2004

a picture of myself

Münsterland.org

2004-02-13

SOAPpy 0.10.1 has a bug with exception handling

Update: I misremembered what version of SOAPpy I had installed. Actually the bug was first listed here as a bug for SOAPpy 0.11.1, but that's wrong. It's SOAPpy 0.10.1 that has the bug. SOAPpy 0.11.1 is working fine. But if you want to upgrade to SOAPpy 0.11.1, you need to use PyDS from current CVS, as older versions are not compatible with SOAPpy 0.11! The next release will require SOAPpy 0.11.1 (and fpconst 0.6.0, as that is needed by SOAPpy 0.11.1).

If you call a function on a remote webservice and that function throws an exception, and if that exception is of type SOAPpy.Types.faultType, the client code automatically should throw a corresponding exception. This doesn't work, because the following code:

p, attrs = parseSOAPRPC(r, attrs = 1)

try:
    
throw_struct = self.throw_faults and \
        
isinstance (p, faultType)
except:
    
throw_struct = 0

if throw_struct:
    
print p
    
raise p

around line 297 in Client.py does check wether the result is an instance of class faultType. But Client.py is missing the necessary import statement and so doesn't know about faultType. As a result you get the faultType instance passed along as call result instead.

To fix it, just go to the head of Client.py and change it as follows:

# SOAPpy modules
from Errors      import *
from Config      import Config
from Parser      import parseSOAPRPC
from SOAPBuilder import buildSOAP
from Utilities   import *

from Types       import *   # <- this line has to be added

That's all, now SOAPpy.Client should throw exceptions just fine. The correct way to don't get exceptions thrown is to pass an optional argument throw_faults=0 to the creation of your SOAPProxy instance.

This post references topics: python
posted at 14:30:40    #
February 2004
MoTuWeThFrSaSu
       1
2 3 4 5 6 7 8
9101112131415
16171819202122
23242526272829
Jan
2004
 Oct
2004

This is the Python Desktop Server weblog.


(Donations will be used by the author to buy stuff, fullfill selfish wishes or do other silly recreational things. You have been warned.).
The PyDS is
OSI Certified Open Source Software

Python Powered

XML-Image

© 2004-2007, Georg Bauer