[Opensrf-commits] r998 - trunk/src/python/osrf

svn at svn.open-ils.org svn at svn.open-ils.org
Thu Jul 5 12:04:35 EDT 2007


Author: erickson
Date: 2007-07-05 12:00:42 -0400 (Thu, 05 Jul 2007)
New Revision: 998

Modified:
   trunk/src/python/osrf/gateway.py
Log:
fixed bug where no-text-data resulted in incorrect array index when parsing hinted objects

Modified: trunk/src/python/osrf/gateway.py
===================================================================
--- trunk/src/python/osrf/gateway.py	2007-07-05 14:53:24 UTC (rev 997)
+++ trunk/src/python/osrf/gateway.py	2007-07-05 16:00:42 UTC (rev 998)
@@ -77,6 +77,9 @@
         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 @@
         return None
 
     def startElement(self, name, attrs):
+        
+        if self.charsPending:
+            # we just read a 'string' or 'number' element that resulted
+            # in no text data.  Appaned a None object
+            self.appendChild(None)
 
-        # XXX add support for serializable objects!
-
         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 @@
             self.objStack.pop()
 
     def characters(self, chars):
+        self.charsPending = False
         self.appendChild(urllib.unquote_plus(chars))
 
 



More information about the opensrf-commits mailing list