[Soap-Python] SOAP Fault

Burak Arslan burak.arslan at arskom.com.tr
Sun Oct 14 22:49:42 CEST 2012


Hello Stefan,

On 10/14/12 15:58, Stefan Andersson wrote:
> Hi,
>
> Had some time to look through the code now and I have come up with 2
> options so far.
>
> Option 1:
> We follow the layout of XmlObject, eg. we move the {to,from}_string
> function from primitive, complex and so on to a new model.py that
> ProtocolBase uses. The new model.py have to include some of the regex
> from primitive in order to work.
>
> Pros: Same layout as XmlObject.
> Cons: Harder to follow the code when you don't have the
> {to,from}_string function in there respective classes.

All in all, I think the option that makes most sense is this one. It's 
actually consistent with the rest of the protocols, not just XmlObject. 
I agree that it could be harder to follow until you wrap your head 
around how Spyne code is organized, but after that, this could be 
forgiven for obviously being consistent with the rest of the code base.

When working on what would become Rpclib-1.x, I'd moved the 
serialization logic out of the model package, but left the 
{from,to}_string logic there because I thought they'd be common to all 
protocols. While I think I was mostly right, the code that is common to 
all protocols should by definition go to ... ProtocolBase :)

> Option 2:
> We let the function stay where they are today and have them raise
> "normal" exception for parsing errors and then catch those in
> ProtocolBase and re-raise them there as ValidationError.
>
> Pros: Easier to follow the code and less changes.
> Cons: Not the same layout as some other modules, catching and
> re-raising new exceptions is wrong according to some.

Well, "transforming" exceptions could be forgiven in some cases, but 
here raising "stub" exceptions and later re-raising real ones makes 
things harder to follow as well and I imagine it'd also hurt performance 
-- remember, your server could receive more invalid input than valid 
input in case someone decides to attack you.

All in all, I think Option 2 would be a very ugly hack for absolutely no 
benefit for the Spyne user, so it's best to go with Option 1.

Best regards,
Burak



More information about the Soap mailing list