aboutsummaryrefslogtreecommitdiffstats
path: root/gsxws
diff options
context:
space:
mode:
authorFilipp Lepalaan <f@230.to>2013-10-12 15:07:45 +0300
committerFilipp Lepalaan <f@230.to>2013-10-12 15:07:45 +0300
commitf9b3ba93e92b4b3de5b093ec6e7fb3f6a6145b7b (patch)
tree2e88d3fa6735fe3f378bce1d936221ae995a4e1c /gsxws
parent3c0c921d8134d4e83676f2f817b2a805df1e5906 (diff)
downloadpy-gsxws-f9b3ba93e92b4b3de5b093ec6e7fb3f6a6145b7b.tar.gz
py-gsxws-f9b3ba93e92b4b3de5b093ec6e7fb3f6a6145b7b.tar.bz2
py-gsxws-f9b3ba93e92b4b3de5b093ec6e7fb3f6a6145b7b.zip
Added GsxObject.dumps()
Diffstat (limited to 'gsxws')
-rw-r--r--gsxws/core.py20
1 files changed, 10 insertions, 10 deletions
diff --git a/gsxws/core.py b/gsxws/core.py
index 61ef0d7..8fba5b5 100644
--- a/gsxws/core.py
+++ b/gsxws/core.py
@@ -39,6 +39,8 @@ import xml.etree.ElementTree as ET
from datetime import date, time, datetime, timedelta
+VERSION = "0.9"
+
GSX_ENV = "it"
GSX_LANG = "en"
GSX_REGION = "emea"
@@ -262,7 +264,7 @@ class GsxRequest(object):
ws = httplib.HTTPSConnection(parsed.netloc, timeout=GSX_TIMEOUT)
ws.putrequest("POST", parsed.path)
- ws.putheader("User-Agent", "py-gsxws 0.9")
+ ws.putheader("User-Agent", "py-gsxws %s" % VERSION)
ws.putheader("Content-type", 'text/xml; charset="UTF-8"')
ws.putheader("Content-length", "%d" % len(xmldata))
ws.putheader("SOAPAction", '"%s"' % method)
@@ -305,9 +307,12 @@ class GsxRequest(object):
self.objects = objectify.parse(xml, response)
return self.objects
- def __str__(self):
+ def __unicode__(self):
return ET.tostring(self.env)
+ def __str__(self):
+ return unicode(self).encode('utf-8')
+
class GsxObject(object):
"XML/SOAP representation of a GSX object"
@@ -390,14 +395,9 @@ class GsxObject(object):
return root
- def __unicode__(self):
- #root = self.to_xml('root')
- #root.append(self._data)
- req = GsxRequest(**{'root': self})
- return ET.tostring(req.data, encoding='UTF-8')
-
- def __str__(self):
- return unicode(self).encode('utf-8')
+ def dumps(self):
+ req = GsxRequest(**{'GsxObject': self})
+ return ET.tostring(req.data, encoding='utf-8')
class GsxRequestObject(GsxObject):