[spyne] Serializing a model
Joseph L. Casale
jcasale at activenetwerx.com
Tue Jun 17 21:27:16 UTC 2014
I am using get_object_as_dict to serialize some data sent to a queue with
the json format.
I have a model which has an xml requirement of:
<node_a ATTR="1st of 2 values"/>
<node_a ATTR="2nd of 2 values"/>
Node_a can only occur zero to two times but must have distinct ATTR values for which
only two exist.
My model is not optimal in that the serialized dict includes 'node_a' values as a list and the
ATTR values as another list so they no longer correlate. I need to know if node_a appears
for which ATTR value it was sent with.
Is their a better way to describe this model while maintaining the nesting structure?
__type_name__ = 'Foo'
_type_info = [
('node_a', Unicode(max_len=450, max_occurs=2)),
('ATTR', XmlAttribute(Unicode(values= ['1st of 2 values', '2nd of 2 values']), attribute_of='node_a'))
More information about the people