added some debugging / sanity checks to python gateway response handler
authorerickson <erickson@9efc2488-bf62-4759-914b-345cdb29e865>
Sun, 23 May 2010 22:26:09 +0000 (22:26 +0000)
committererickson <erickson@9efc2488-bf62-4759-914b-345cdb29e865>
Sun, 23 May 2010 22:26:09 +0000 (22:26 +0000)
git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1956 9efc2488-bf62-4759-914b-345cdb29e865

src/python/osrf/gateway.py

index a71d02d..eda1139 100644 (file)
@@ -69,14 +69,15 @@ class JSONGatewayRequest(GatewayRequest):
         obj = to_object(data)
 
         if obj['status'] != 200:
-            sys.stderr.write('JSON gateway returned status %d:\n%s\n' % (obj['status'], s))
+            sys.stderr.write('JSON gateway returned status %d:\n' % (obj['status']))
             return None
 
         # the gateway wraps responses in an array to handle streaming data
         # if there is only one item in the array, it (probably) wasn't a streaming request
         p = obj['payload']
         if len(p) > 1: return p
-        return p[0]
+        if len(p): return p[0]
+        return None
 
     def encodeParam(self, param):
         return osrf.json.to_json(param)