[Fedora-suds-list] Creating an element with both attribute and value
Erik Cederstrand
erik at cederstrand.dk
Fri Jul 16 06:29:02 UTC 2010
Den 15/07/2010 kl. 12.13 skrev Erik Cederstrand:
> Hi
>
> I have an element defined in my XSD which I create like this:
>
> myobject.Body = create('t:BodyType')
>
> It expects both an attribute and some content:
>
> <ns0:Body BodyType="Text">
> Hello from Suds!
> </ns0:Body>
>
> I can specify the attribute like this:
>
> myobject.Body._BodyType = "Text"
>
> But how do I add my content? If I just do this:
>
> myobject.Body = "Hello from Suds!"
> myobject.Body._BodyType = "Text"
>
> , Python complains about myobject.Body being a string. According to http://osdir.com/ml/fedora-suds-list/2010-05/msg00012.html, I should use:
>
> myobject.Body.value = "Hello from Suds!"
> myobject.Body._BodyType = "Text"
>
> , but it just complains that:
>
> suds.TypeNotFound: Type not found: 'value'
>
> Did I just hit bug #323 (https://fedorahosted.org/suds/ticket/323)?
I managed to solve my problem with a minimal patch, attached to https://fedorahosted.org/suds/ticket/323
It allows setting a value on an element like this:
myobject.MyElement.value = Property("Hello from Suds!")
myobject.MyElement._MyAttribute = "123"
producing
<MyElement MyAttribute="123">Hello from Suds!</MyElement>
I would like some comments on this. Is it the correct way to solve the problem?
Thanks,
Erik
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 1928 bytes
Desc: not available
Url : http://lists.fedoraproject.org/pipermail/suds/attachments/20100716/0aa3e891/attachment.bin
More information about the suds
mailing list