2013-04-24 82 views
0

我在玩attribute_of和spyne 2.10(非常高興)。讓我們考慮以下模型:屬性的名稱自定義

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

這給了類似的結果:

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

如何自定義edition_id的名字像<edition id="..."/>結果?

回答

1

從2.10開始,Spyne不支持這一點。

我想不出一個簡單的解決方法,因爲它需要編寫method_call和method_return_document事件以及wsdl事件來手動修補wsdl。但是,如果你可以爲它編寫測試,我會看看我能爲2.11做些什麼。

+0

下週我會投入一些時間來解決這個問題。謝謝。 – kbec 2013-04-25 08:00:59

+0

嗨,請看看https://github.com/plq/spyne/blob/72665943092378a6d49460e21adeb95845dd4de5/examples/xml_utils.py#L78並告訴我你的想法。 – 2013-05-19 13:38:27

相關問題