commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

r6697 - trunk/gnue-common/src/datasources/drivers/Base


From: reinhard
Subject: r6697 - trunk/gnue-common/src/datasources/drivers/Base
Date: Thu, 18 Nov 2004 05:03:52 -0600 (CST)

Author: reinhard
Date: 2004-11-18 05:03:51 -0600 (Thu, 18 Nov 2004)
New Revision: 6697

Modified:
   trunk/gnue-common/src/datasources/drivers/Base/ResultSet.py
Log:
Make findRecord move to -1 if no match is found.


Modified: trunk/gnue-common/src/datasources/drivers/Base/ResultSet.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/Base/ResultSet.py 2004-11-18 
00:09:26 UTC (rev 6696)
+++ trunk/gnue-common/src/datasources/drivers/Base/ResultSet.py 2004-11-18 
11:03:51 UTC (rev 6697)
@@ -123,11 +123,16 @@
 
 
   # Move to a record number already in cache
+  # -1 sets the current record to None
   def __move (self, record):
     if record != self._currentRecord \
-         or self.current != self._cachedRecords [self._currentRecord]:
+         or (self._currentRecord >= 0 \
+             and self.current != self._cachedRecords [self._currentRecord]):
       self._currentRecord = record
-      self.current = self._cachedRecords [self._currentRecord]
+      if record == -1:
+        self.current = None
+      else:
+        self.current = self._cachedRecords [self._currentRecord]
       self.notifyDetailObjects ()
       self.__notifyListeners ()
 
@@ -231,7 +236,14 @@
     This function searches through the already loaded records and sets the
     current record to the first record to match the given fieldValues
     dictionary (in the form {fieldname: value}).
+    If no match is found, then the record pointer is set to -1.
     """
+
+    # Make sure that all records are cached
+    while self._cacheNextRecord():
+      pass
+
+    # Find match
     for i in range (len (self._cachedRecords)):
       record = self._cachedRecords [i]
       found = True
@@ -243,6 +255,10 @@
         self.__move (i)
         return self.current
 
+    # No match found
+    self.__move (-1)
+    return self.current
+
   # ---------------------------------------------------------------------------
   # Get data as array
   # ---------------------------------------------------------------------------





reply via email to

[Prev in Thread] Current Thread [Next in Thread]