fixed bug where no-text-data resulted in incorrect array index when parsing hinted...
authorerickson <erickson@9efc2488-bf62-4759-914b-345cdb29e865>
Thu, 5 Jul 2007 16:00:42 +0000 (16:00 +0000)
committererickson <erickson@9efc2488-bf62-4759-914b-345cdb29e865>
Thu, 5 Jul 2007 16:00:42 +0000 (16:00 +0000)
git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@998 9efc2488-bf62-4759-914b-345cdb29e865

src/python/osrf/gateway.py

index c9f9392..190afce 100644 (file)
@@ -77,6 +77,9 @@ class XMLGatewayParser(handler.ContentHandler):
         self.keyStack = []
         self.posStack = [] # for tracking array-based hinted object indices
 
+        # true if we are parsing an element that may have character data
+        self.charsPending = 0 
+
     def getResult(self):
         return self.result
 
@@ -87,13 +90,20 @@ class XMLGatewayParser(handler.ContentHandler):
         return None
 
     def startElement(self, name, attrs):
-
-        # XXX add support for serializable objects!
+        
+        if self.charsPending:
+            # we just read a 'string' or 'number' element that resulted
+            # in no text data.  Appaned a None object
+            self.appendChild(None)
 
         if name == 'null':
             self.appendChild(None)
             return
 
+        if name == 'string' or name == 'number':
+            self.charsPending = True
+            return
+
         if name == 'element': # this is an object item wrapper
             self.keyStack.append(self.__getAttr(attrs, 'key'))
             return
@@ -157,6 +167,7 @@ class XMLGatewayParser(handler.ContentHandler):
             self.objStack.pop()
 
     def characters(self, chars):
+        self.charsPending = False
         self.appendChild(urllib.unquote_plus(chars))