[spyne] defining a service without expecting namespace in every tag

Daniele Bortoluzzi daniele at elkos.it
Tue Aug 11 14:24:54 UTC 2015


On 11 August 2015 at 15:29, Burak Arslan <burak.arslan at arskom.com.tr> wrote:

>
>
> On 08/11/15 15:28, Daniele Bortoluzzi wrote:
> > I saw that _body_style='bare' could be the solution.
>
>
Burak, I found the source of the argument number problem.

Following the examples/user_manager/server_sqlalchemy.py. I was overriding
the Application.call_wrapper()

class MySoapApp(Application):
    def call_wrapper(self, ctx):
        try:
            return ctx.service_class.call_wrapper(ctx)

        except KeyError:
            raise ResourceNotFoundError(ctx.in_object)

which, in turn, calls the ServiceBase.call_wrapper():

    def call_wrapper(cls, ctx):
        if ctx.function is not None:
            if ctx.descriptor.no_ctx:
                return ctx.function(*ctx.in_object)
            else:
                return ctx.function(ctx, *ctx.in_object)

unpacking (star operator) the input object means that the ctx.function will
receive the object attributes instead of the "container".
With _body_style='bare' you must have only one input argument so the
wrapper should not unpack the in_object.

Removing the overridden call_wrapper() from my code does the job, because
the "unpacking problem" is correctly managed in the original
Application.call_wrapper():

        if ctx.descriptor.body_style is BODY_STYLE_BARE:
            ctx.in_object = [ctx.in_object]
        elif ctx.descriptor.body_style is BODY_STYLE_EMPTY:
            ctx.in_object = []

According to the Spyne manual ("How Exactly is User Code Wrapped?")
ServiceBase.call_wrapper() is called *after* Application.call_wrapper(), so
when you override this function you must be sure that there are no
unpacking issues, right?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spyne.io/archives/people/attachments/20150811/4970e5ee/attachment.html>


More information about the people mailing list