[Soap-Python] Default values for parameters

azurIt azurit at pobox.sk
Tue Sep 27 10:25:56 CEST 2011


Thanks, i created new issue.

That lxml validation fixed few things (for example when i send string to Integer parameter) but parameters count is still a problem. Also String(nillable=True) doesn't seems to have any effect. I tried:

@rpc(String(nillable=False), String(nillable=False), _returns=String)
def testf(self, first, second):

calling (SUDS):
client.service.testf("aaa", "")
client.service.testf("aaa", None)
client.service.testf("aaa")

Everything passes and function gets None as second argument in all cases.


______________________________________________________________
> Od: "Burak Arslan" <burak.arslan at arskom.com.tr>
> Komu: azurIt <azurit at pobox.sk>
> Dátum: 27.09.2011 00:43
> Predmet: Re: [Soap-Python] Default values for parameters
>
> CC: soap at python.org
>hello,
>
>you're asking good questions :)
>
>On 09/26/11 20:08, azurIt wrote:
>> Hi,
>>
>> how can i set default values for arguments ? Standard python way is not working:
>> @rpc(String, String, _returns=String)
>> def testf(self, first, second=u"aaa"):
>>      ....
>>
>
>that won't work. the ideal way would be to have a default keyword (e.g.
>String(default='something')) but such a thing is not implemented. use if
>val is None: val = some_value idiom. if you need this bad, add it to the
>issue tracker so that i can work on it when I have some free time.
>
>> Thx.
>>
>> Btw, rpclib seems to not check parameters count. If function is taking two parameters and i send only one, everything is processed without error (and second parameters gets None). The similar thing will happen if i send more than 2 params.
>>
>
>the wisdom in the it world says: "be liberal in what you receive and
>conservative on what you send", so validation is an opt-in feature in
>rpclib.
>
>if you're using soap, you can use strict ('lxml') or 'soft' validation.
>httprpc only supports 'soft' validation.
>
>This is how you should instantiate your application:
>Application(services, 'some.tns', Wsdl11(), Soap11(validator='lxml'),
>Soap11())
>
>'lxml' validation will complain about the slightest irregularity in the
>input. soft validation will only validate the designated values and
>ignore the rest.
>
>now that you have validation enabled, you must make parameters
>mandatory. you should set, e.g. Integer(min_occurs=1, nillable=False) or
>String(min_occurs=1, nillable=False, min_len=1). see the api reference
>to see which type accepts which constraints.
>
>also see here as a shortcut to specifying all that:
>https://github.com/arskom/rpclib/blob/master/src/rpclib/model/primitive.py#L466
>
>hth
>burak
>
>> azur
>> _______________________________________________
>> Soap mailing list
>> Soap at python.org
>> http://mail.python.org/mailman/listinfo/soap
>
>


More information about the Soap mailing list