Changeset 3125
- Timestamp:
- 05/11/07 10:29:30 (1 year ago)
- Files:
-
- branches/stable/dabo/biz/dBizobj.py (modified) (7 diffs)
- trunk/dabo/biz/dBizobj.py (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/stable/dabo/biz/dBizobj.py
r3118 r3125 60 60 self._caption = "" 61 61 self._dataSource = "" 62 self._scanRestorePosition = None 62 self._scanRestorePosition = True 63 self._scanReverse = False 63 64 self._SQL = "" 64 65 self._requeryOnLoad = False … … 542 543 543 544 544 def scan(self, func, reverse=False,*args, **kwargs):545 def scan(self, func, *args, **kwargs): 545 546 """Iterate over all records and apply the passed function to each. 546 547 … … 548 549 549 550 If self.ScanRestorePosition is True, the position of the current 550 record in the recordset is restored after the iteration. If the 'reverse'551 parameteris True, the records are processed in reverse order.552 """ 553 self.scanRows(func, range(self.RowCount), reverse=reverse,*args, **kwargs)554 555 556 def scanRows(self, func, rows, reverse=False,*args, **kwargs):551 record in the recordset is restored after the iteration. If 552 self.ScanReverse is True, the records are processed in reverse order. 553 """ 554 self.scanRows(func, range(self.RowCount), *args, **kwargs) 555 556 557 def scanRows(self, func, rows, *args, **kwargs): 557 558 """Iterate over the specified rows and apply the passed function to each. 558 559 559 560 Set self.exitScan to True to exit the scan on the next iteration. 560 561 """ 562 561 563 # Flag that the function can set to prematurely exit the scan 562 564 self.exitScan = False 563 565 rows = list(rows) 564 if self.ScanRestorePosition: 565 try: 566 currPK = self.getPK() 567 currRow = None 568 except: 569 # No PK defined 570 currPK = None 571 currRow = self.RowNumber 572 try: 573 if reverse: 566 try: 567 currPK = self.getPK() 568 currRow = None 569 except: 570 # No PK defined 571 currPK = None 572 currRow = self.RowNumber 573 574 def restorePosition(): 575 if self.ScanRestorePosition: 576 if currPK is not None: 577 self._positionUsingPK(currPK, updateChildren=False) 578 else: 579 try: 580 self.RowNumber = currRow 581 except StandardError, e: 582 # Perhaps the row was deleted; at any rate, leave the pointer 583 # at the end of the data set 584 row = self.RowCount - 1 585 if row >= 0: 586 self.RowNumber = row 587 588 try: 589 if self.ScanReverse: 574 590 rows.reverse() 575 591 for i in rows: … … 578 594 if self.exitScan: 579 595 break 580 except dException.dException, e: 581 if self.ScanRestorePosition: 582 self.RowNumber = currRow 583 raise dException.dException, e 584 585 if self.ScanRestorePosition: 586 if currPK is not None: 587 self._positionUsingPK(currPK, updateChildren=False) 588 else: 589 try: 590 self.RowNumber = currRow 591 except StandardError, e: 592 # Perhaps the row was deleted; at any rate, leave the pointer 593 # at the end of the data set 594 row = self.RowCount - 1 595 if row >= 0: 596 self.RowNumber = row 596 except Exception, e: 597 restorePosition() 598 raise 599 restorePosition() 600 601 597 602 598 603 … … 1071 1076 if val is None: 1072 1077 val = self.getParentPK() 1073 self.scan(self._setParentFK, val =val)1078 self.scan(self._setParentFK, val) 1074 1079 1075 1080 def _setParentFK(self, val): … … 1751 1756 1752 1757 1758 def _getScanReverse(self): 1759 return self._scanReverse 1760 1761 def _setScanReverse(self, val): 1762 self._scanReverse = val 1763 1764 1753 1765 def _getSQL(self): 1754 1766 try: … … 1911 1923 at the end of the recordset (False). (bool)""")) 1912 1924 1925 ScanReverse = property(_getScanReverse, _setScanReverse, None, 1926 _("""Do we scan the records in reverse order? (Default: False) (bool)""")) 1927 1913 1928 SQL = property(_getSQL, _setSQL, None, 1914 1929 _("SQL statement used to create the cursor's data. (str)")) trunk/dabo/biz/dBizobj.py
r3122 r3125 60 60 self._caption = "" 61 61 self._dataSource = "" 62 self._scanRestorePosition = None 62 self._scanRestorePosition = True 63 self._scanReverse = False 63 64 self._SQL = "" 64 65 self._requeryOnLoad = False … … 557 558 558 559 559 def scan(self, func, reverse=False,*args, **kwargs):560 def scan(self, func, *args, **kwargs): 560 561 """Iterate over all records and apply the passed function to each. 561 562 … … 563 564 564 565 If self.ScanRestorePosition is True, the position of the current 565 record in the recordset is restored after the iteration. If the 'reverse'566 parameteris True, the records are processed in reverse order.567 """ 568 self.scanRows(func, range(self.RowCount), reverse=reverse,*args, **kwargs)569 570 571 def scanRows(self, func, rows, reverse=False,*args, **kwargs):566 record in the recordset is restored after the iteration. If 567 self.ScanReverse is True, the records are processed in reverse order. 568 """ 569 self.scanRows(func, range(self.RowCount), *args, **kwargs) 570 571 572 def scanRows(self, func, rows, *args, **kwargs): 572 573 """Iterate over the specified rows and apply the passed function to each. 573 574 574 575 Set self.exitScan to True to exit the scan on the next iteration. 575 576 """ 577 576 578 # Flag that the function can set to prematurely exit the scan 577 579 self.exitScan = False 578 580 rows = list(rows) 579 if self.ScanRestorePosition: 580 try: 581 currPK = self.getPK() 582 currRow = None 583 except: 584 # No PK defined 585 currPK = None 586 currRow = self.RowNumber 587 try: 588 if reverse: 581 try: 582 currPK = self.getPK() 583 currRow = None 584 except: 585 # No PK defined 586 currPK = None 587 currRow = self.RowNumber 588 589 def restorePosition(): 590 if self.ScanRestorePosition: 591 if currPK is not None: 592 self._positionUsingPK(currPK, updateChildren=False) 593 else: 594 try: 595 self.RowNumber = currRow 596 except StandardError, e: 597 # Perhaps the row was deleted; at any rate, leave the pointer 598 # at the end of the data set 599 row = self.RowCount - 1 600 if row >= 0: 601 self.RowNumber = row 602 603 try: 604 if self.ScanReverse: 589 605 rows.reverse() 590 606 for i in rows: … … 593 609 if self.exitScan: 594 610 break 595 except dException.dException, e: 596 if self.ScanRestorePosition: 597 self.RowNumber = currRow 598 raise dException.dException, e 599 600 if self.ScanRestorePosition: 601 if currPK is not None: 602 self._positionUsingPK(currPK, updateChildren=False) 603 else: 604 try: 605 self.RowNumber = currRow 606 except StandardError, e: 607 # Perhaps the row was deleted; at any rate, leave the pointer 608 # at the end of the data set 609 row = self.RowCount - 1 610 if row >= 0: 611 self.RowNumber = row 611 except Exception, e: 612 restorePosition() 613 raise 614 restorePosition() 612 615 613 616 … … 1086 1089 if val is None: 1087 1090 val = self.getParentPK() 1088 self.scan(self._setParentFK, val =val)1091 self.scan(self._setParentFK, val) 1089 1092 1090 1093 def _setParentFK(self, val): … … 1766 1769 1767 1770 1771 def _getScanReverse(self): 1772 return self._scanReverse 1773 1774 def _setScanReverse(self, val): 1775 self._scanReverse = val 1776 1777 1768 1778 def _getSQL(self): 1769 1779 try: … … 1926 1936 at the end of the recordset (False). (bool)""")) 1927 1937 1938 ScanReverse = property(_getScanReverse, _setScanReverse, None, 1939 _("""Do we scan the records in reverse order? (Default: False) (bool)""")) 1940 1928 1941 SQL = property(_getSQL, _setSQL, None, 1929 1942 _("SQL statement used to create the cursor's data. (str)"))
