Changeset 3210

Show
Ignore:
Timestamp:
06/23/07 12:12:27 (2 years ago)
Author:
ed
Message:

Added the _syncWithCursors() method that should ensure that all cursors have the current values set in the bizobj before executing any SQL statements.

Files:

Legend:

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

    r3209 r3210  
    5858 
    5959        # Various attributes used for Properties 
     60        self._autoCommit = False 
    6061        self._caption = "" 
    6162        self._dataSource = "" 
     63        self._nonUpdateFields = [] 
    6264        self._scanRestorePosition = True 
    6365        self._scanReverse = False 
     
    133135        if self.__cursors: 
    134136            _dataStructure = getattr(self.__cursors[self.__cursors.keys()[0]], "_dataStructure", None) 
    135             _virtualFields = getattr(self.__cursors[self.__cursors.keys()[0]], "_virtualFields", {}) 
     137            self._virtualFields = getattr(self.__cursors[self.__cursors.keys()[0]], "_virtualFields", {}) 
    136138        else: 
    137139            # The first cursor is being created, before DataStructure is assigned. 
    138140            _dataStructure = None 
    139             _virtualFields = {} 
     141            self._virtualFields = {} 
    140142        errMsg = self.beforeCreateCursor() 
    141143        if errMsg: 
     
    155157        if _dataStructure is not None: 
    156158            crs._dataStructure = _dataStructure 
    157         crs._virtualFields = _virtualFields 
     159        crs._virtualFields = self._virtualFields 
    158160        crs.KeyField = self.KeyField 
    159161        crs.Table = self.DataSource 
     
    494496    def execute(self, sql): 
    495497        """Execute the sql on the cursor. Dangerous. Use executeSafe instead.""" 
     498        self._syncWithCursors() 
    496499        return self._CurrentCursor.execute(sql) 
    497500 
     
    503506        main cursor. 
    504507        """ 
     508        self._syncWithCursors() 
    505509        return self._CurrentCursor.executeSafe(sql) 
    506510 
     
    14481452 
    14491453 
     1454    def _syncWithCursors(self): 
     1455        """Many bizobj properties need to be passed through to the cursors 
     1456        that provide it with data connectivity. This method ensures that all 
     1457        such cursors are in sync with the bizobj. 
     1458        """ 
     1459        for crs in self.__cursors.values(): 
     1460            crs.AutoCommit = self._autoCommit 
     1461            crs.AutoPopulatePK = self._autoPopulatePK 
     1462            crs.AutoQuoteNames = self._autoQuoteNames 
     1463            crs.Table = self._dataSource 
     1464            crs.VirtualFields = self._virtualFields 
     1465            crs.Encoding = self.Encoding 
     1466            crs.KeyField = self._keyField 
     1467            crs.setNonUpdateFields(self._nonUpdateFields) 
     1468     
     1469 
    14501470    def _getAutoCommit(self): 
    14511471        return self._CurrentCursor.AutoCommit 
    14521472 
    14531473    def _setAutoCommit(self, val): 
    1454         for crs in self.__cursors.values(): 
    1455            crs.AutoCommit = val 
     1474        self._autoCommit = val 
     1475        self._syncWithCursors() 
    14561476 
    14571477 
     
    14641484    def _setAutoPopulatePK(self, val): 
    14651485        self._autoPopulatePK = bool(val) 
    1466         for crs in self.__cursors.values(): 
    1467             crs.AutoPopulatePK = val 
     1486        self._syncWithCursors() 
    14681487 
    14691488 
     
    14731492    def _setAutoQuoteNames(self, val): 
    14741493        self._autoQuoteNames = val 
    1475         for crs in self.__cursors.values(): 
    1476             crs.AutoQuoteNames = val 
     1494        self._syncWithCursors() 
    14771495 
    14781496 
     
    15261544    def _setDataSource(self, val): 
    15271545        self._dataSource = str(val) 
    1528         for crs in self.__cursors.values(): 
    1529             crs.Table = val 
     1546        self._syncWithCursors() 
    15301547 
    15311548 
     
    15591576 
    15601577    def _setVirtualFields(self, val): 
    1561         for crs in self.__cursors.values(): 
    1562             crs.VirtualFields = val 
    15631578        self._virtualFields = val 
     1579        self._syncWithCursors() 
    15641580 
    15651581 
    15661582    def _getEncoding(self): 
    1567         ret = None 
    1568         cursor = self._CurrentCursor 
    1569         if cursor is not None: 
    1570             ret = cursor.Encoding 
    1571         if ret is None: 
    1572             if self.Application: 
    1573                 ret = self.Application.Encoding 
    1574             else: 
    1575                 ret = dabo.defaultEncoding 
     1583        try: 
     1584            ret = self._encoding 
     1585        except AttributeError: 
     1586            ret = None 
     1587            cursor = self._CurrentCursor 
     1588            if cursor is not None: 
     1589                ret = cursor.Encoding 
     1590            if ret is None: 
     1591                if self.Application: 
     1592                    ret = self.Application.Encoding 
     1593                else: 
     1594                    ret = dabo.defaultEncoding 
     1595            self._encoding = ret 
    15761596        return ret 
    15771597 
    15781598    def _setEncoding(self, val): 
    1579         for crs in self.__cursors.values(): 
    1580            crs.Encoding = val 
     1599        self._encoding = val 
     1600        self._syncWithCursors() 
    15811601 
    15821602 
     
    16031623    def _setKeyField(self, val): 
    16041624        self._keyField = val 
    1605         for crs in self.__cursors.values(): 
    1606             crs.KeyField = val 
     1625        self._syncWithCursors() 
    16071626 
    16081627 
     
    16511670        if fldList is None: 
    16521671            fldList = [] 
    1653         for crs in self.__cursors.values(): 
    1654            crs.setNonUpdateFields(fldList
     1672        self._nonUpdateFields = fldList 
     1673        self._syncWithCursors(
    16551674 
    16561675