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 | |
parent | 4bf636657270c25e2931a6a8c75db7959cb66dc0 (diff) | |
download | py-gsxws-dc661e006b4c3f035ef2a090745678ccf212839c.tar.gz py-gsxws-dc661e006b4c3f035ef2a090745678ccf212839c.tar.bz2 py-gsxws-dc661e006b4c3f035ef2a090745678ccf212839c.zip |
Fixing nesting in GsxObject to_xml
-rw-r--r-- | gsxws/core.py | 10 | ||||
-rw-r--r-- | gsxws/repairs.py | 1 |
2 files changed, 9 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 diff --git a/gsxws/repairs.py b/gsxws/repairs.py index 6355d3a..6e84477 100644 --- a/gsxws/repairs.py +++ b/gsxws/repairs.py @@ -45,6 +45,7 @@ class Repair(GsxObject): requestReview = False customerAddress = None purchaseOrderNumber = "" + orderLines = [] _namespace = "asp:" |