commit-gnue
[Top][All Lists]
Advanced

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

[gnue] r6912 - trunk/gnue-appserver/src


From: johannes
Subject: [gnue] r6912 - trunk/gnue-appserver/src
Date: Thu, 20 Jan 2005 08:22:34 -0600 (CST)

Author: johannes
Date: 2005-01-20 08:22:33 -0600 (Thu, 20 Jan 2005)
New Revision: 6912

Modified:
   trunk/gnue-appserver/src/data.py
   trunk/gnue-appserver/src/geasList.py
Log:
Reimplemented dirty reads.


Modified: trunk/gnue-appserver/src/data.py
===================================================================
--- trunk/gnue-appserver/src/data.py    2005-01-18 09:13:46 UTC (rev 6911)
+++ trunk/gnue-appserver/src/data.py    2005-01-20 14:22:33 UTC (rev 6912)
@@ -44,6 +44,9 @@
           % {'table': table, 'row': row, 'state': state}
     errors.SystemError.__init__ (self, msg)
 
+class OrderBySequenceError (errors.ApplicationError):
+  pass
+
 # =============================================================================
 # Cache class
 # =============================================================================
@@ -116,7 +119,7 @@
 
   def __has (self, table, row, field, dirty):
 
-    result = 0
+    result = False
 
     if dirty:
       tables = self.__new
@@ -128,7 +131,7 @@
       if rows.has_key (row):
         fields = rows [row]
         if fields.has_key (field):
-          result = 1
+          result = True
 
     return result
 
@@ -136,7 +139,7 @@
   # Return whether a certain value is stored in the cache or not
   # ---------------------------------------------------------------------------
 
-  def has (self, table, row, field):
+  def has (self, table, row, field, dirty = None):
     """
     Return true (1) if the given item is stored in the cache (either in a clean
     or in a dirty version). Return false (0) if it isn't.
@@ -145,19 +148,21 @@
     checktype (row, UnicodeType)
     checktype (field, UnicodeType)
 
-    if self.__has (table, row, field, 1) or self.__has (table, row, field, 0):
-      return 1
+    if dirty is None:
+      return self.__has (table, row, field, True) or \
+             self.__has (table, row, field, False)
     else:
-      return 0
+      return self.__has (table, row, field, dirty)
 
   # ---------------------------------------------------------------------------
   # Read data from the cache
   # ---------------------------------------------------------------------------
 
-  def read (self, table, row, field):
+  def read (self, table, row, field, dirty = True):
     """
-    Read data from the cache. This always returns the current version, no
-    matter if it's dirty or not.
+    Read data from the cache. Depending on the dirty-flag set this function
+    returns the current version, no matter if it's dirty or not. If the
+    dirty-flag is False only the field's old value will be returned.
 
     If the given item isn't available, an exception is raised.
     """
@@ -165,7 +170,7 @@
     checktype (row, UnicodeType)
     checktype (field, UnicodeType)
 
-    if self.__has (table, row, field, 1):
+    if dirty and self.__has (table, row, field, 1):
       tables = self.__new               # Data is in dirty cache
     else:
       tables = self.__old               # Data isn't in dirty cache, so search
@@ -174,6 +179,7 @@
     fields = rows [row]
     return fields [field]
 
+
   # ---------------------------------------------------------------------------
   # Get the status of a record
   # ---------------------------------------------------------------------------
@@ -224,6 +230,7 @@
             return 'changed'
         return ''                       # row has no dirty fields
 
+
   # ---------------------------------------------------------------------------
   # List all tables with dirty records
   # ---------------------------------------------------------------------------
@@ -515,7 +522,15 @@
 def _createResultSet (connections, database, content, conditions, order):
 
   datasource = _createDatasource (connections, database, content, order)
+  return datasource.createResultSet (_conditionTree (conditions))
 
+
+# -----------------------------------------------------------------------------
+# Create a condition tree of a given condition
+# -----------------------------------------------------------------------------
+
+def _conditionTree (conditions):
+
   if isinstance (conditions, ListType):
     cTree = GConditions.buildTreeFromList (conditions)
 
@@ -525,8 +540,9 @@
   else:
     cTree = conditions
 
-  return datasource.createResultSet (cTree)
+  return cTree
 
+
 # -----------------------------------------------------------------------------
 # Create a result set containing only one row, identified by the gnue_id
 # -----------------------------------------------------------------------------
@@ -624,7 +640,7 @@
       for fields_element in fields: checktype (fields_element, UnicodeType)
 
     return recordset (self.__cache, self.__connections, self.__database,
-                      content, conditions, order)
+                      content, _conditionTree (conditions), order)
 
   # ---------------------------------------------------------------------------
   # Generate a new object id
@@ -907,11 +923,19 @@
     self.__connections = connections
     self.__database    = database
     self.__content     = content
+    self.__order       = order
 
     # make sure gnue_id is selected for all tables
     for (alias, (table, fk_alias, fk_field, fields)) in self.__content.items():
       fields.append (u'gnue_id')
 
+    self.__add     = []
+    self.__added   = 0
+    self.__remove  = {}
+    self.__mergeWithCache (conditions, order)
+
+    self.__current   = None
+    self.__isFirst   = True
     self.__resultSet = _createResultSet (self.__connections, self.__database,
                                          self.__content, conditions, order)
 
@@ -920,10 +944,79 @@
   # ---------------------------------------------------------------------------
 
   def count (self):
+    """
+    This function returns the number of records in this result set.
+    """
 
-    return self.__resultSet.getRecordCount ()
+    return self.__resultSet.getRecordCount () + \
+        len (self.__add) + self.__added - len (self.__remove.keys ())
 
+
   # ---------------------------------------------------------------------------
+  # Return the next record
+  # ---------------------------------------------------------------------------
+
+  def nextRecord (self):
+    """
+    Returns the next record or None if nothing is left.  If the query affected
+    more than one table, the record for the main table (i.e. the table that is
+    the root of all other references) is returned.
+    """
+
+    # if no more records are scheduled for addition, return the next usable
+    # record from the backend
+    if not len (self.__add):
+      rec = self.__nextBackendRecord ()
+      self.__current = None
+      return rec
+
+    else:
+      if not len (self.__order):
+        row = self.__add [0]
+        self.__add.remove (row)
+        self.__added += 1
+        return record (self.__cache, self.__connections, self.__database,
+                       self.__getMasterTable (), row)
+      else:
+        row = self.__add [0]
+        rec = self.__nextBackendRecord ()
+
+        if rec is not None:
+          rid   = rec.getField (u'gnue_id')
+          left  = SortRecord (row, self.__getSortSequence (row, self.__order))
+          right = SortRecord (rid, self.__getSortSequence (rid, self.__order))
+
+          useAdd = cmp (left, right) <= 0
+        else:
+          useAdd = True
+
+        if useAdd:
+          self.__add.remove (row)
+          self.__added += 1
+          return record (self.__cache, self.__connections, self.__database,
+                         self.__getMasterTable (), row)
+        else:
+          self.__current = None
+          return rec
+
+
+  # ---------------------------------------------------------------------------
+  # Close the record set
+  # ---------------------------------------------------------------------------
+
+  def close (self):
+    """
+    This function closes a record set which is no longer needed. It closes the
+    underlying result set.
+    """
+
+    if self.__resultSet is not None:
+      self.__resultSet.close ()
+
+    self.__resultSet = None
+
+
+  # ---------------------------------------------------------------------------
   # Build record objects from current recordSet
   # ---------------------------------------------------------------------------
 
@@ -967,54 +1060,352 @@
 
 
   # ---------------------------------------------------------------------------
-  # Return the first record
+  # Get the next record from the backend source
   # ---------------------------------------------------------------------------
 
-  def firstRecord (self):
+  def __nextBackendRecord (self):
     """
-    Returns the first record or None if the set is empty.  If the query
-    affected more than one table, the record for the main table (i.e. the table
-    that is the root of all other references) is returned.
+    This function returns the next usable record from the backend. If there's
+    a record in the queue from a previous access it will be used first. Every
+    record retrieved from the backend will be checked if it is to be removed
+    (listed in the remove queue).
+
+    @return: record instance of the next usable backend record or None if no
+        more records are available.
     """
 
-    if self.__resultSet.firstRecord () is None:
-      return None
-    else:
-      return self.__buildRecords ()
+    # If there is no record instance left from an earlier call, we fetch one
+    if self.__current is None:
+      if self.__isFirst:
+        beRec = self.__resultSet.firstRecord ()
+        self.__isFirst = False
+      else:
+        beRec = self.__resultSet.nextRecord ()
 
+      if beRec is None:
+        return None
+
+      self.__current = self.__buildRecords ()
+
+    # Now, have a look if the instance has to be removed
+    if self.__remove.has_key (self.__current.getRow ()):
+      self.__current = None
+      res = self.__nextBackendRecord ()
+
+    return self.__current
+
+
   # ---------------------------------------------------------------------------
-  # Return the next record
+  # Get the name of the master table of this recordset
   # ---------------------------------------------------------------------------
 
-  def nextRecord (self):
+  def __getMasterTable (self):
     """
-    Returns the next record or None if nothing is left.  If the query affected
-    more than one table, the record for the main table (i.e. the table that is
-    the root of all other references) is returned.
+    This function returns the name of the master table of the recordset
+    @return: name of the master table (=table without fk_alias)
     """
+    result = None
 
-    if self.__resultSet.nextRecord () is None:
-      return None
+    for (alias, (table, fk_alias, fk_field, fields)) in self.__content.items():
+      if not fk_alias:
+        result = table
+        break
+
+    return result
+
+
+
+  # ---------------------------------------------------------------------------
+  # Merge cache 
+  # ---------------------------------------------------------------------------
+
+  def __mergeWithCache (self, conditions, order):
+    """
+    """
+
+    # If the master table is not listed in the dirty cache, we have nothing to
+    # do, since everything which is in clean cache will not colide with the
+    # backend's result
+    tables = self.__cache.dirtyTables ()
+    master = self.__getMasterTable ()
+
+    if not tables.has_key (master):
+      return
+
+    # Iterate over all dirty rows of the master table and stick them into the
+    # apropriate filter
+    for (row, fields) in tables [master].items ():
+      state = self.__cache.status (master, row)
+
+      if state == 'inserted':
+        # an inserted (new) row must match the current condition
+        self.__addFilter (row, conditions)
+
+      elif state == 'changed':
+        # if a changed row has a modified condition we stick it both into the
+        # 'append' and the 'remove' filter
+        if self.__conditionChanged (row, conditions):
+          self.__addFilter (row, conditions)
+          self.__removeFilter (row, conditions)
+        else:
+          # otherwise we have to analyze the sort order
+          if self.__sortOrderChanged (row, order):
+            # if the sortorder has changed we remove it from the old position
+            # and insert it at the new one
+            self.__remove [row] = True
+            self.__add.append (row)
+
+      elif state == 'deleted':
+        # a deleted row must match the current condition with it's *original*
+        # values
+        self.__removeFilter (row, conditions)
+
+    # If we have a sort order defined, we need to sort all records listed for
+    # addition
+    if len (order) and len (self.__add):
+      self.__sortAddition (order)
+
+
+  # ---------------------------------------------------------------------------
+  # Filter with destination 'add'
+  # ---------------------------------------------------------------------------
+
+  def __addFilter (self, row, condition):
+    """
+    This function implements a filter for rows heading for the 'add'
+    destination. Every row must meet the conditions specified in order to get
+    in.
+    """
+
+    if condition is not None:
+      lookup = self.__getLookupDictionary (condition, row)
+      if not condition.evaluate (lookup):
+        return
+
+    self.__add.append (row)
+
+
+  # ---------------------------------------------------------------------------
+  # Filter with destination 'remove'
+  # ---------------------------------------------------------------------------
+
+  def __removeFilter (self, row, condition):
+    """
+    This function implements a filter for rows heading for the 'remove'
+    destination. Every row must match the condition with it's *original* fields
+    in order to get in.
+    """
+
+    if condition is not None:
+      lookup = self.__getLookupDictionary (condition, row, True)
+      if not condition.evaluate (lookup):
+        return
+
+    self.__remove [row] = True
+
+
+  # ---------------------------------------------------------------------------
+  # Create a lookup dictionary for condition-evaluation
+  # ---------------------------------------------------------------------------
+
+  def __getLookupDictionary (self, condition, row, original = False):
+    """
+    This function creates a dictionary with all fields listed in a given
+    condition as keys and their values based on the given row.
+
+    @param condition: GCondition tree with the conditions
+    @param row: gnue_id of the master record to fetch values from
+    @param original: if True, the original (clean) values will be used,
+        otherwise the current values will be used.
+    @return: dictionary with fields and their values
+    """
+    
+    result = {}
+
+    for condfield in condition.findChildrenOfType ('GCCField', True, True):
+      path  = self.__getPropertyPath (condfield.name)
+      result [condfield.name] = self.__getPathValue (row, path, original)
+
+    return result
+      
+
+  # ---------------------------------------------------------------------------
+  # Get the value for a property specified in a path
+  # ---------------------------------------------------------------------------
+
+  def __getPathValue (self, row, path, original = False):
+    """
+    This function returns the value of the property defined by the given path
+    sequence, starting with the first element using a gnue_id of 'row'.
+    @param path: sequence of tuples (alias, table, field) describing the
+        property.
+    @param row: gnue_id of the record to be used for the first path element
+    @param original: if True the original (clean) values are returned,
+        otherwise the current values will be returned.
+    @return: value of the property
+    """
+
+    value = None
+    for (alias, table, field) in path:
+      r = record (self.__cache, self.__connections, self.__database, table, 
row)
+
+      value = r.getField (field, original)
+      row   = value
+
+      if value is None:
+        break
+
+    return value
+
+
+  # ---------------------------------------------------------------------------
+  # Check if a field in a condition has changed
+  # ---------------------------------------------------------------------------
+
+  def __conditionChanged (self, row, condition):
+    """
+    This function iterates over all fields of a condition and returns True if a
+    field has been changed or False otherwise.
+
+    @param row: gnue_id of the record to check the condition for
+    @param condition: GCondition tree with the condition or None
+    @return: True if a condition field has been changed, False otherwise
+    """
+
+    if condition is not None:
+      for condfield in condition.findChildrenOfType ('GCCField', True, True):
+        path    = self.__getPropertyPath (condfield.name)
+        if self.__fieldIsChanged (row, path):
+          return True
+
+    return False
+
+
+  # ---------------------------------------------------------------------------
+  # Check wether a field in the sort order has changed or not
+  # ---------------------------------------------------------------------------
+
+  def __sortOrderChanged (self, row, order):
+    """
+    This function checks if a field in the sort order has been changed.
+
+    @param row: gnue_id of the record to check the sort order for
+    @param order: sequence with the sort order tuples
+    @return: True if a field has been changed, False otherwise
+    """
+    
+    for (field, direction) in order:
+      path = self.__getPropertyPath (field)
+      if self.__fieldIsChanged (row, path):
+        return True
+
+    return False
+
+
+  # ---------------------------------------------------------------------------
+  # Check if a field has been changed
+  # ---------------------------------------------------------------------------
+
+  def __fieldIsChanged (self, row, path):
+    """
+    This function checks wether a field (described by a path) has been changed
+    or not.
+
+    @param row: gnue_id of the record to check the sort order for
+    @param path: sequence of tuples (alias, table, field) describing the
+        property.
+    @return: True if the field has been changed, False otherwise
+    """
+
+    # A path of length one is a normal property without any references.
+    # In this case if the property hasn't been changed, everything's fine.
+    if len (path) == 1:
+      (alias, table, field) = path [0]
+      if not self.__cache.has (table, row, field, True):
+        return False
+
+    # Otherwise we need to compare the original and the current value
+    oldvalue = self.__getPathValue (row, path, original = True)
+    current  = self.__getPathValue (row, path)
+
+    return cmp (oldvalue, current) != 0
+
+
+  # ---------------------------------------------------------------------------
+  # Create a path to access a given property
+  # ---------------------------------------------------------------------------
+
+  def __getPropertyPath (self, name):
+    """
+    This function creates a path to access a given property based on the
+    content-dictionary. 
+    @param: property name including alias and fieldname, separated by a dot
+    @return: sequence of tuples (alias, tablename, fieldname)
+    """
+
+    result = []
+    if '.' in name:
+      (alias, field) = name.split ('.', 1)
     else:
-      return self.__buildRecords ()
+      (alias, field) = (None, name)
 
+    if self.__content.has_key (alias):
+      (table, fk_alias, fk_field, fields) = self.__content [alias]
+      # add a tuple to the result
+      result.append ((alias, table, field))
 
+      if fk_alias is not None:
+        add = self.__getPropertyPath ("%s.%s" % (fk_alias, fk_field))
+        # after finishing recursion add all inner tuples to the result,
+        # maintaining sort order
+        for ix in xrange (len (add)):
+          result.insert (ix, add [ix])
+
+    return result
+
+
   # ---------------------------------------------------------------------------
-  # Close the record set
+  # Sort all records which we have to merge in
   # ---------------------------------------------------------------------------
 
-  def close (self):
+  def __sortAddition (self, order):
     """
-    This function closes a record set which is no longer needed. It closes the
-    underlying result set.
+    This function sorts all records from the cache to fit the current sort
+    order.
+    @param order: sort-sequence to be used
     """
 
-    if self.__resultSet is not None:
-      self.__resultSet.close ()
+    if len (self.__add) > 1:
+      seq = []
+      for row in self.__add:
+        seq.append (SortRecord (row, self.__getSortSequence (row, order)))
 
-    self.__resultSet = None
+      seq.sort ()
+      self.__add = [item.row for item in seq]
 
 
+  # ---------------------------------------------------------------------------
+  # Create a sort sequence for a sort order and a given record
+  # ---------------------------------------------------------------------------
+
+  def __getSortSequence (self, row, order):
+    """
+    This function creates a sequence of tuples (fieldvalue, direction) for the
+    record specified by 'row' using the given sortorder.
+
+    @param row: gnue_id of the record to fetch fieldvalues from
+    @param order: sequence of (fieldname, order) tuples specifing the sort 
order
+    @return: sort sequence of tuples (value, direction)
+    """
+
+    result = []
+    for (field, direction) in order:
+      path = self.__getPropertyPath (field)
+      result.append ((self.__getPathValue (row, path), direction))
+
+    return result
+
+
 # =============================================================================
 # Record class
 # =============================================================================
@@ -1022,8 +1413,8 @@
 class record:
   """
   This class stands for a record in a database table. An instance of this class
-  can be created via the recordset.firstRecord() and recordset.nextRecord()
-  methods, or by the connection.findRecord() method.
+  can be created via the recordset.nextRecord() methods, or by the
+  connection.findRecord() method.
   """
 
   # ---------------------------------------------------------------------------
@@ -1038,7 +1429,17 @@
     self.__table       = table
     self.__row         = row
 
+
   # ---------------------------------------------------------------------------
+  # Get the gnue_id of the record
+  # ---------------------------------------------------------------------------
+
+  def getRow (self):
+
+    return self.__row
+
+
+  # ---------------------------------------------------------------------------
   # Cache a single value for this record
   # ---------------------------------------------------------------------------
 
@@ -1065,7 +1466,7 @@
   # Get the value for a field
   # ---------------------------------------------------------------------------
 
-  def getField (self, field):
+  def getField (self, field, original = False):
     """
     Get the value for a field. If the value isn't cached, a new query to the
     database is issued to get the value.
@@ -1076,30 +1477,34 @@
     """
     checktype (field, UnicodeType)
 
-    if self.__cache.has (self.__table, self.__row, field):
-      # If we find the field in the cache, use it
-      return self.__cache.read (self.__table, self.__row, field)
+    if original:
+      if self.__cache.has (self.__table, self.__row, field, False):
+        return self.__cache.read (self.__table, self.__row, field, False)
     else:
-      # if state is one of 'in*' the record is new and cannot exist in the
-      # backend.
-      if self.status () in ['initializing', 'initialized', 'inserted']:
+      if self.__cache.has (self.__table, self.__row, field):
+        # If we find the field in the cache, use it
+        return self.__cache.read (self.__table, self.__row, field)
+
+    # if state is one of 'in*' the record is new and cannot exist in the
+    # backend.
+    if self.status () in ['initializing', 'initialized', 'inserted']:
+      return None
+
+    # Not found in cache, so get it from the db
+    resultSet = _find (self.__connections, self.__database, self.__table,
+                       self.__row, [field])
+    try:
+      if resultSet.current is not None:
+        value = resultSet.current [field]
+        self.__cache.write (self.__table, self.__row, field, value, 0)
+        return value
+      else:
         return None
 
-      # Not found in cache, so get it from the db
-      resultSet = _find (self.__connections, self.__database, self.__table,
-                         self.__row, [field])
-      try:
-        if resultSet.current is not None:
-          value = resultSet.current [field]
-          self.__cache.write (self.__table, self.__row, field, value, 0)
-          return value
-        else:
-          return None
+    finally:
+      resultSet.close ()
 
-      finally:
-        resultSet.close ()
 
-
   # ---------------------------------------------------------------------------
   # Put the value for a field
   # ---------------------------------------------------------------------------
@@ -1152,8 +1557,99 @@
 
     self.__cache.touch (self.__table, self.__row, dirty)
 
+  # ---------------------------------------------------------------------------
+  # Give an official string represenation of the record instance
+  # ---------------------------------------------------------------------------
 
+  def __repr__ (self):
+    """
+    This function returns an official string representation of the record
+    instance.
+    """
+
+    return "<record of table '%s', row '%s'>" % (self.__table, self.__row)
+      
+
 # =============================================================================
+# This class implements a sortable hull for record instances
+# =============================================================================
+
+class SortRecord:
+
+  # ---------------------------------------------------------------------------
+  # Constructor
+  # ---------------------------------------------------------------------------
+
+  def __init__ (self, row, sorting = None):
+
+    self.nullFirstAsc = gConfig ('null_first_asc')
+    self.nullFirstDsc = gConfig ('null_first_dsc')
+    self.row          = row
+    self.sorting      = sorting
+
+
+  # ---------------------------------------------------------------------------
+  # Comparison of two instances
+  # ---------------------------------------------------------------------------
+
+  def __cmp__ (self, other):
+    """
+    This function implements the comparison of two instances.
+    """
+
+    # If this or the other instance has no order-by rule, just do the
+    # default-compare for instances
+    if self.sorting is None or other.sorting is None:
+      return cmp (self, other)
+
+    # If both instance have an order-by rule, they must match in length
+    if len (self.sorting) != len (other.sorting):
+      raise OrderBySequenceError, \
+          u_("Order-by sequence mismatch: '%(self)s' and '%(other)s'") \
+          % {'self': self.sorting, 'other': other.sorting}
+
+    for ix in xrange (len (self.sorting)):
+      (left, descending)  = self.sorting [ix]
+      (right, rightOrder) = other.sorting [ix]
+
+      if descending != rightOrder:
+        raise OrderBySequenceError, \
+            u_("Order-by sequence element has different directions: "
+               "'%(self)s', '%(other)s'") \
+            % {'self': self.sorting [ix], 'other': other.sorting [ix]}
+
+      noneOpt = self.nullFirstAsc
+      if descending:
+        (left, right) = (right, left)
+        noneOpt = not self.nullFirstDsc
+
+      if None in [left, right]:
+        if not noneOpt:
+          (left, right) = (right, left)
+        result = cmp (left, right)
+      else:
+        result = cmp (left, right)
+
+      if result != 0:
+        return result
+
+    # If no field gave a result, the two instances are treated to be equal
+    return 0
+
+
+  # ---------------------------------------------------------------------------
+  # Official string representation
+  # ---------------------------------------------------------------------------
+
+  def __repr__ (self):
+    """
+    This function returns an official string representation of the sort record
+    """
+
+    return "<SortRecord for row %s at %s>" % (self.row, hex (id (self)))
+
+
+# =============================================================================
 # Self test code
 # =============================================================================
 
@@ -1174,8 +1670,8 @@
   rs = c.query (content, None, [(u't0.address_name', True)])
   print 'Ok'
 
-  print 'recordset.firstRecord ...',
-  r = rs.firstRecord ()
+  print 'recordset.nextRecord ...',
+  r = rs.nextRecord ()
   print 'Ok'
 
   print 'record.getField with prefetched data ...',
@@ -1233,8 +1729,8 @@
                        ['const', u'New Person']], None)
   print 'Ok'
 
-  print 'recordset.firstRecord ...',
-  r = rs.firstRecord ()
+  print 'recordset.nextRecord ...',
+  r = rs.nextRecord ()
   print 'Ok'
 
   print 'record.getField with prefetched data ...',
@@ -1289,7 +1785,7 @@
                 ['eq', ['field', u'address_city'],
                        ['const', u'New City']],
                 None)
-  if rs.firstRecord () != None:
+  if rs.nextRecord () != None:
     raise Exception
   print 'Ok'
 

Modified: trunk/gnue-appserver/src/geasList.py
===================================================================
--- trunk/gnue-appserver/src/geasList.py        2005-01-18 09:13:46 UTC (rev 
6911)
+++ trunk/gnue-appserver/src/geasList.py        2005-01-20 14:22:33 UTC (rev 
6912)
@@ -85,14 +85,14 @@
       if len (self.__unsorted):
         current = self.__unsorted.pop ()
       else:
-        current = self.__getInstance (len (self.__instances) == 0)
+        current = self.__getInstance ()
 
       while self.__wantMore (count) and current is not None:
         group = self.__getGroup (current)
 
         while current is not None and self.__getGroup (current) == group:
           self.__unsorted.append (current)
-          current = self.__getInstance (False)
+          current = self.__getInstance ()
 
         if len (self.__unsorted) > 1:
           self.__sortBatch ()
@@ -122,7 +122,7 @@
     """
 
     while self.__wantMore (count):
-      current = self.__getInstance (len (self.__instances) == 0)
+      current = self.__getInstance ()
       if current is not None:
         self.__instances.append (current)
 
@@ -146,17 +146,13 @@
   # Get the next usable instance and add it to the instance list
   # ---------------------------------------------------------------------------
 
-  def __getInstance (self, fromStart = False):
+  def __getInstance (self):
     """
     This function fetches the next usable instance from the recordset according
     to the list's condition. This instance will be returned as function result.
     """
 
-    if fromStart:
-      record = self.__recordset.firstRecord ()
-    else:
-      record = self.__recordset.nextRecord ()
-
+    record = self.__recordset.nextRecord ()
     self.__isComplete = record is None
 
     if record is not None:





reply via email to

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