diff options
author | Filipp Lepalaan <f@230.to> | 2013-05-13 17:34:29 +0300 |
---|---|---|
committer | Filipp Lepalaan <f@230.to> | 2013-05-13 17:34:29 +0300 |
commit | 59d7edde59e4bc3b4064a1fb3f36eb20393ff646 (patch) | |
tree | cc339ed28c68e429256d0694fa7ab60791b4c922 /gsxws/core.py | |
parent | 8e3cdccde7d29a77e8227266c4986690f7dce10f (diff) | |
download | py-gsxws-59d7edde59e4bc3b4064a1fb3f36eb20393ff646.tar.gz py-gsxws-59d7edde59e4bc3b4064a1fb3f36eb20393ff646.tar.bz2 py-gsxws-59d7edde59e4bc3b4064a1fb3f36eb20393ff646.zip |
Convert file data
Diffstat (limited to 'gsxws/core.py')
-rw-r--r-- | gsxws/core.py | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/gsxws/core.py b/gsxws/core.py index 5cd0261..59f23dd 100644 --- a/gsxws/core.py +++ b/gsxws/core.py @@ -292,14 +292,23 @@ class GsxObject(object): super(GsxObject, self).__setattr__(name, value) return + if isinstance(value, file): + if not hasattr(self, "fileName"): + super(GsxObject, self).__setattr__("fileName", value.name) + value = base64.b64encode(value.read()) + if isinstance(value, int): value = str(value) + if isinstance(value, date): value = value.strftime(self._formats['df']) + if isinstance(value, time): value = value.strftime(self._formats['tf']) + if isinstance(value, bool): value = "Y" if value else "N" + if isinstance(value, date): value = value.strftime(self._formats['df']) @@ -330,20 +339,12 @@ class GsxObject(object): el = ET.SubElement(root, k) if isinstance(v, basestring): el.text = v - if isinstance(v, dict): - for a, b in v.items(): - i = ET.SubElement(el, a) - i.text = b if isinstance(v, GsxObject): el.append(v.to_xml(k)) if isinstance(v, list): for e in v: if isinstance(e, GsxObject): el.append(e.to_xml(k)) - else: # Assuming dict. @TODO: yuck... - for a, b in e.items(): - i = ET.SubElement(el, a) - i.text = b return root |