The Spyne manual points out that the right way to create SOAP Faults with Spyne is to raise instances of spyne.model.fault.Fault
(or your own subclass):
@add_metaclass(ComplexModelMeta)
class Fault(ComplexModelBase, Exception):
# ...
I'm trying to understand why it subclasses ComplexModelBase
. My initial assumption was that I declare the elements I want to go into the SOAP Fault's <detail>
element in my Fault
subclass, like so:
class MyApplicationError(Fault):
__namespace__ = 'http://myapplication.com/ns'
_type_info = [
('reason', Unicode),
]
However, when actually raising this exception, it looks like I have to pass a plain dict into the detail
parameter of the constructor.
What is the best practice for filling the detail
with a structured set of data? Do I even declare this structure in my Fault
subclass?
If yes, how do I fill it? If not, why does Fault
subclass ComplexModelBase
?