[spyne] Spyne and complex model tree structures
burak.arslan at arskom.com.tr
Thu Jul 7 20:49:08 UTC 2016
On 07/05/16 16:19, Marduk wrote:
> But it's impossible to declare Array(TreeNode) from inside TreeNode
> because TreeNode isn't visible from it self. So is it possible to
> somehow declare this complex type and send it to spyne?
Yes, two ways:
1. Use SelfReference. ie
children = Array(SelfReference)
See the testcases:
2. Use append_field or insert_field. ie
i = Integer
Beware that Spyne can only serialize DAGs (DAG == directed acyclic
graph) without any efforts towards breaking cycles. In other words, if
an object somehow ends up referring to itself, only recursion error will
terminate serialization. (Trees are DAGs so you should be fine here)
Among the supported protocols, only SOAP supports serializing cyclic
graphs (via references, see
https://www.w3.org/TR/2000/NOTE-SOAP-20000508/#_Toc478383520) but it's
not implemented. Patches are welcome!
One exception, log_repr, breaks cycles by serializing objects only once.
Other occurrences are serialized as only a simple ellipsis.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the people