aboutsummaryrefslogtreecommitdiffstats
path: root/gsxws
diff options
context:
space:
mode:
Diffstat (limited to 'gsxws')
-rw-r--r--gsxws/core.py26
-rw-r--r--gsxws/repairs.py1
-rw-r--r--gsxws/returns.py5
3 files changed, 14 insertions, 18 deletions
diff --git a/gsxws/core.py b/gsxws/core.py
index a49ea6f..b6b237a 100644
--- a/gsxws/core.py
+++ b/gsxws/core.py
@@ -145,42 +145,40 @@ class GsxError(Exception):
class GsxCache(object):
"""
- The cache creates a separate shelf for each GSX session.
-
- >>> GsxCache('test').set('spam', 'eggs').get('spam')
+ >>> GsxCache('spam').set('eggs').get()
'eggs'
"""
shelf = None
tmpdir = tempfile.gettempdir()
+ filename = os.path.join(tmpdir, "gsxws.tmp")
def __init__(self, key, expires=timedelta(minutes=20)):
self.key = key
self.expires = expires
self.now = datetime.now()
- filename = os.path.join(self.tmpdir, "gsxws_%s.db" % key)
- self.shelf = shelve.open(filename, protocol=-1)
+ self.shelf = shelve.open(self.filename, protocol=-1)
if not self.shelf.get(key):
# Initialize the key
- self.set(key, None)
+ self.set(None)
- def get(self, key):
+ def get(self):
try:
- d = self.shelf[key]
+ d = self.shelf[self.key]
if d['expires'] > self.now:
return d['value']
else:
- del self.shelf[key]
+ del self.shelf[self.key]
except KeyError:
return None
- def set(self, key, value):
+ def set(self, value):
d = {
'value': value,
'expires': self.now + self.expires
}
- self.shelf[key] = d
+ self.shelf[self.key] = d
return self
@@ -467,14 +465,14 @@ class GsxSession(GsxObject):
def login(self):
global GSX_SESSION
- if not self._cache.get("session") is None:
- GSX_SESSION = self._cache.get("session")
+ if not self._cache.get() is None:
+ GSX_SESSION = self._cache.get()
else:
self._req = GsxRequest(AuthenticateRequest=self)
result = self._req._submit("Authenticate")
self._session_id = result[0].userSessionId
GSX_SESSION = self.get_session()
- self._cache.set("session", GSX_SESSION)
+ self._cache.set(GSX_SESSION)
return GSX_SESSION
diff --git a/gsxws/repairs.py b/gsxws/repairs.py
index 878d4ab..d18498d 100644
--- a/gsxws/repairs.py
+++ b/gsxws/repairs.py
@@ -37,7 +37,6 @@ class Customer(GsxObject):
class RepairOrderLine(GsxObject):
partNumber = ""
- partNumber = ""
comptiaCode = ""
comptiaModifier = ""
diff --git a/gsxws/returns.py b/gsxws/returns.py
index f46690e..0810c15 100644
--- a/gsxws/returns.py
+++ b/gsxws/returns.py
@@ -120,9 +120,8 @@ class Return(GsxObject):
'comptiaModifier': 'A',\
'returnType': 2}])
"""
- rd = GsxObject(repairConfirmationNumber=confirmation)
- rd.orderLines = parts
- self.repairData = rd
+ self.repairConfirmationNumber = confirmation
+ self.orderLines = parts
self._submit("repairData", "UpdateCarryIn", "repairConfirmation")
return self._req.objects[0]