Changeset 3116

Show
Ignore:
Timestamp:
05/09/07 06:47:01 (2 years ago)
Author:
paul
Message:

Removed self.scanRestorePosition and self.scanReverse. Replaced the former with the 'ScanRestorePosition?' property. The latter is now an optional parameter to the scan() method.

(backported from trunk commit [3115])

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/stable/dabo/biz/dBizobj.py

    r3093 r3116  
    4949        self._baseClass = dBizobj 
    5050        self.__areThereAnyChanges = False   # Used by the isChanged() method. 
    51         # Next two are used by the scan() method. 
    52         self.__scanRestorePosition = True 
    53         self.__scanReverse = False 
    5451        # Used by the LinkField property 
    5552        self._linkField = "" 
     
    6360        self._caption = "" 
    6461        self._dataSource = "" 
     62        self._scanRestorePosition = None 
    6563        self._SQL = "" 
    6664        self._requeryOnLoad = False 
     
    544542 
    545543 
    546     def scan(self, func, *args, **kwargs): 
     544    def scan(self, func, reverse=False, *args, **kwargs): 
    547545        """Iterate over all records and apply the passed function to each. 
    548546 
    549547        Set self.exitScan to True to exit the scan on the next iteration. 
    550548 
    551         If self.__scanRestorePosition is True, the position of the current 
    552         record in the recordset is restored after the iteration. If 
    553         self.__scanReverse is true, the records are processed in reverse order. 
    554         """ 
    555         self.scanRows(func, range(self.RowCount), *args, **kwargs) 
    556  
    557  
    558     def scanRows(self, func, rows, *args, **kwargs): 
     549        If self.ScanRestorePosition is True, the position of the current 
     550        record in the recordset is restored after the iteration. If the 'reverse' 
     551        parameter is 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): 
    559557        """Iterate over the specified rows and apply the passed function to each. 
    560558 
     
    564562        self.exitScan = False 
    565563        rows = list(rows) 
    566         if self.__scanRestorePosition: 
     564        if self.ScanRestorePosition: 
    567565            try: 
    568566                currPK = self.getPK() 
     
    573571                currRow = self.RowNumber 
    574572        try: 
    575             if self.__scanReverse: 
     573            if reverse: 
    576574                rows.reverse() 
    577575            for i in rows: 
     
    581579                    break 
    582580        except dException.dException, e: 
    583             if self.__scanRestorePosition: 
     581            if self.ScanRestorePosition: 
    584582                self.RowNumber = currRow 
    585583            raise dException.dException, e 
    586584 
    587         if self.__scanRestorePosition: 
     585        if self.ScanRestorePosition: 
    588586            if currPK is not None: 
    589587                self._positionUsingPK(currPK, updateChildren=False) 
     
    17461744 
    17471745 
     1746    def _getScanRestorePosition(self): 
     1747        return self._scanRestorePosition 
     1748 
     1749    def _setScanRestorePosition(self, val): 
     1750        self._scanRestorePosition = val 
     1751 
     1752 
    17481753    def _getSQL(self): 
    17491754        try: 
     
    18751880 
    18761881    RequeryOnLoad = property(_getRequeryOnLoad, _setRequeryOnLoad, None, 
    1877             _("""When true, the cursor object runs its query immediately. This 
     1882            _("""When True, the cursor object runs its query immediately. This 
    18781883            is useful for lookup tables or fixed-size (small) tables. (bool)""")) 
    18791884 
     
    19011906            this behavior, set this to True.  (bool)""")) 
    19021907     
     1908    ScanRestorePosition = property(_getScanRestorePosition, _setScanRestorePosition, None, 
     1909            _("""After running a scan, do we attempt to restore the record position to  
     1910            where it was before the scan (True, default), or do we leave the pointer  
     1911            at the end of the recordset (False). (bool)""")) 
     1912     
    19031913    SQL = property(_getSQL, _setSQL, None, 
    19041914            _("SQL statement used to create the cursor's data. (str)")) 
     
    19151925            The specified function will be called when getFieldVal() is called on  
    19161926            the specified virtual field name.""")) 
    1917