Name customization for attribute_of

2019-08-28 11:31发布

问题:

I'm playing with attribute_of and spyne 2.10 (very glad it's out). Let's consider following model:

class Product(ComplexModel):
    id = complex.XmlAttribute(primitive.Uuid)
    edition = primitive.Unicode
    edition_id = complex.XmlAttribute(primitive.Uuid, attribute_of='edition')

That gives results like:

<product id="00000000-0000-0000-0000-000000000000">
    <edition edition_id="00000000-0000-0000-0000-000000000000">My edition</edition>
</product>

How to customize edition_id's name for results like <edition id="..."/>?

回答1:

As of 2.10, Spyne does not support this.

I can't think of an easy workaround as it'd require writing method_call and method_return_document events as well as wsdl events to patch the wsdl manually.

However, if you can write tests for it, I'll see what I can do for the 2.11.