diff options
author | Filipp Lepalaan <f@230.to> | 2013-05-13 15:43:43 +0300 |
---|---|---|
committer | Filipp Lepalaan <f@230.to> | 2013-05-13 15:43:43 +0300 |
commit | dc661e006b4c3f035ef2a090745678ccf212839c (patch) | |
tree | 2365712860ae948384ccfb1889ee04646028d0bc /gsxws/core.py | |
parent | 4bf636657270c25e2931a6a8c75db7959cb66dc0 (diff) | |
download | py-gsxws-dc661e006b4c3f035ef2a090745678ccf212839c.tar.gz py-gsxws-dc661e006b4c3f035ef2a090745678ccf212839c.tar.bz2 py-gsxws-dc661e006b4c3f035ef2a090745678ccf212839c.zip |
Fixing nesting in GsxObject to_xml
Diffstat (limited to 'gsxws/core.py')
-rw-r--r-- | gsxws/core.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/gsxws/core.py b/gsxws/core.py index cd35386..d9ce56b 100644 --- a/gsxws/core.py +++ b/gsxws/core.py @@ -319,7 +319,10 @@ class GsxObject(object): """ Returns this object as an XML Element - >>> GsxObject(spam='eggs', spices=['salt', 'pepper']) + >>> GsxObject(spam='eggs', spices=[{'salt': 'pepper'}]) #doctest: +ELLIPSIS + <__main__.GsxObject object at 0x... + >>> GsxObject(spam='eggs', spices=[{'salt': 'pepper'}]).to_xml('blaa') #doctest: +ELLIPSIS + <Element 'blaa' at 0x... """ root = ET.Element(root) for k, v in self._data.items(): @@ -332,7 +335,10 @@ class GsxObject(object): el.append(v.to_xml(k)) if isinstance(v, list): for e in v: - el.append(e) + if isinstance(v, GsxObject): + el.append(e.to_xml(k)) + else: # assuming it's a dict... + el.append(GsxObject(**e).to_xml(k)) return root |