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

Daniele Bortoluzzi daniele at elkos.it
Thu Aug 27 08:45:26 UTC 2015


On 26 August 2015 at 16:03, Daniele Bortoluzzi <daniele at elkos.it> wrote:

> [...]
>
> Now I'm in trouble again: I have namespaces put in every tag:
> [...]
>

Well, I read those posts:

http://stackoverflow.com/q/16420036/1334425
https://github.com/arskom/spyne/issues/274

I understand that I cannot make xml elements "unqualified". As a temporary
workaround, I added a listener to Service event 'method_return_document',
manually stripping namespaces:

def clean_inner_namespaces(ctx):
    if ctx.function.__name__ == 'Notify':
        treepath = "/senv:Envelope/senv:Body/tns:NotifyResponse/child::*"
        to_clean = ctx.out_document.xpath(treepath,
namespaces=ctx.out_document.nsmap)
        for el in to_clean:
            el.tag = etree.QName(el).localname

MyService.event_manager.add_listener('method_return_document',
                                                clean_inner_namespaces)

Thank you,

D
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spyne.io/archives/people/attachments/20150827/c7427ed3/attachment.html>


More information about the people mailing list