Returning Fault instances in xmlrpc

Brian Quinlan brian at sweetapp.com
Sun May 5 02:56:09 EDT 2002


> Well... I beg to differ :)
> 
> Returning an error code (which a Fault object is, basically) is
> different from raising an exception (very different). Exception
> handling includes a completely separate set of control structures.

They do use a different set of control structures at the protocol level.
Return values use the "params" element, while exceptions use the "fault"
element.

This is from the XML-RPC spec:

"""Can the <fault> struct contain other members than <faultCode> and
<faultString>? Is there a global list of faultCodes? (so they can be
mapped to distinct exceptions for languages like Python and Java)?"""

So the specification is talking about XML-RPC faults as if they can be
mapped to exceptions!
 
> Is that true for Boolean, DateTime, or Binary objects? If so, the
> server is seriously broken. If not, I find it strange that Fault
> objects are the only ones that are not handled according to specs.

I'm starting to suspect that you are being deliberately obtuse. Boolean,
DateTime and Binary objects are stand-ins for XML-RPC types that have no
Python equivalents. 

I think that if the server were seriously broken, someone would have
discovered it by now. 
 
> (The fact that instances can be returned at all seems odd to me -- how
> is the set of attributes computed? From obj.__dict__ or by pulling
> down attributes from superclasses etc.? 

Using obj.__dict__

> I would have preferred a "refusal to guess" here, requiring the use of

> a mapping when you want to return a mapping.)

I probably would not have implemented it this way either. But classes
are the closest thing that Python has to C-style structs so one could
make the argument...

Cheers,
Brian






More information about the Python-list mailing list