dabo Commit
Revision 6034
Date: 2010-09-26 06:15:52 -0700 (Sun, 26 Sep 2010)
Author: Ed
Trac: http://trac.dabodev.com/changeset/6034

Changed:
U   trunk/dabo/biz/dBizobj.py

Log:
At the suggestion of Jacek Ka?\197?\130ucki, I've added a variation of the 
bizIterator named 'bizDataIterator', which returns a dict containing the 
columns/values of the current record in the iteration.


Diff:
Modified: trunk/dabo/biz/dBizobj.py
===================================================================
--- trunk/dabo/biz/dBizobj.py   2010-09-23 02:00:04 UTC (rev 6033)
+++ trunk/dabo/biz/dBizobj.py   2010-09-26 13:15:52 UTC (rev 6034)
@@ -717,13 +717,23 @@
 
        def bizIterator(self):
                """Returns an iterator that moves the bizobj's record pointer 
from
-               the first record to the last. You may call the iterator's 
reverse() method
-               before beginning iteration in order to iterate from the last 
record
-               back to the first.
+               the first record to the last, and returns the current record 
number.
+               You may call the iterator's reverse() method before beginning
+               iteration in order to iterate from the last record back to the 
first.
                """
                return _bizIterator(self)
 
 
+       def bizDataIterator(self):
+               """Returns an iterator that moves the bizobj's record pointer 
from
+               the first record to the last, and returns a dict of the 
columns/values
+               of the record for the current iteration. You may call the 
iterator's
+               reverse() method before beginning iteration in order to iterate 
from
+               the last record back to the first.
+               """
+               return _bizIterator(self, returnRecords=True)
+
+
        def scan(self, func, *args, **kwargs):
                """Iterate over all records and apply the passed function to 
each.
 
@@ -2561,8 +2571,9 @@
 
 
 class _bizIterator(object):
-       def __init__(self, obj):
+       def __init__(self, obj, returnRecords=False):
                self.obj = obj
+               self.returnRecords = returnRecords
                self.__firstpass = True
                self.__nextfunc = self._next
 
@@ -2589,7 +2600,10 @@
                                self.obj.prior()
                        except dException.BeginningOfFileException:
                                raise StopIteration
-               return self.obj.RowNumber
+               if self.returnRecords:
+                       return self.obj.getDataSet(rowStart=self.obj.RowNumber, 
rows=1)[0]
+               else:
+                       return self.obj.RowNumber
 
 
        def _next(self):
@@ -2604,7 +2618,10 @@
                                self.obj.next()
                        except dException.EndOfFileException:
                                raise StopIteration
-               return self.obj.RowNumber
+               if self.returnRecords:
+                       return self.obj.getDataSet(rowStart=self.obj.RowNumber, 
rows=1)[0]
+               else:
+                       return self.obj.RowNumber
 
 
        def next(self):



_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: 
http://leafe.com/archives/byMID/[email protected]

Reply via email to