[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r7303 - trunk/gnue-common/src/datasources/drivers/Base
From: |
reinhard |
Subject: |
[gnue] r7303 - trunk/gnue-common/src/datasources/drivers/Base |
Date: |
Wed, 6 Apr 2005 13:30:22 -0500 (CDT) |
Author: reinhard
Date: 2005-04-06 13:30:21 -0500 (Wed, 06 Apr 2005)
New Revision: 7303
Modified:
trunk/gnue-common/src/datasources/drivers/Base/RecordSet.py
Log:
Merged _postChanges into post, as no descendant has to overwrite this any more.
Modified: trunk/gnue-common/src/datasources/drivers/Base/RecordSet.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/Base/RecordSet.py 2005-04-06
18:14:00 UTC (rev 7302)
+++ trunk/gnue-common/src/datasources/drivers/Base/RecordSet.py 2005-04-06
18:30:21 UTC (rev 7303)
@@ -404,9 +404,38 @@
# If we have a connection (i.e. we aren't static or unbound), do the post
if self._parent._dataObject._connection:
- gDebug (8, 'Posting datasource %s' % self._parent._dataObject.name)
- self._postChanges (recordNumber)
+ do = self._parent._dataObject
+ gDebug (8, 'Posting datasource %s' % do.name)
+ if self._deleteFlag:
+ do._connection.delete (do.table, self.__wherefields (), recordNumber)
+
+ elif self._insertFlag or self._updateFlag:
+ modifiedFields = {}
+ for field in self._modifiedFlags.keys ():
+ if self._parent.isFieldBound (field):
+ modifiedFields [field] = self._fields [field]
+
+ if self._insertFlag:
+ rowid = do._connection.insert (do.table, modifiedFields,
recordNumber)
+ if self.__rowidField:
+ self._fields [self.__rowidField] = rowid
+ self._initialData [self.__rowidField] = rowid
+ # Requery all the fields that are important for inserting details.
+ # A backend trigger could have e.g. generated a primary key.
+ if self.__detailLinkFlags:
+ self.__requery (self.__detailLinkFlags.keys ())
+
+ else:
+ do._connection.update (do.table, self.__wherefields (),
+ modifiedFields, recordNumber)
+
+ # The record is now "clean" again
+ self._insertFlag = False
+ self._updateFlag = False
+ self._modifiedFlags = {}
+ self._initialData = self._fields.copy ()
+
# Post all detail records
for child in (self._cachedDetailResultSets.values ()):
do = child._dataObject
@@ -562,51 +591,3 @@
return "<RecordSet for %s>" % do.table
else:
return "<Unbound/Static RecordSet>"
-
- # ---------------------------------------------------------------------------
- # Virtual methods to be overwritten by the drivers
- # ---------------------------------------------------------------------------
-
- def _postChanges (self, recno = None):
- """
- Post any changes (deletes, inserts, and updates) to the database.
-
- Descendants can either override this function, or the three functions
- _insert, _update, and _delete of the Connection object (the latter is
- recommended).
-
- _postChanges is guaranteed to be only called for records that have pending
- changes. Implementations of this function can check the kind of pending
- change by querying the _deleteFlag, _insertFlag, and _updateFlag instance
- variables.
- """
- do = self._parent._dataObject
-
- if self._deleteFlag:
- do._connection.delete (do.table, self.__wherefields (), recno)
-
- elif self._insertFlag or self._updateFlag:
- modifiedFields = {}
- for field in self._modifiedFlags.keys ():
- if self._parent.isFieldBound (field):
- modifiedFields [field] = self._fields [field]
-
- if self._insertFlag:
- rowid = do._connection.insert (do.table, modifiedFields, recno)
- if self.__rowidField:
- self._fields [self.__rowidField] = rowid
- self._initialData [self.__rowidField] = rowid
- # Requery all the fields that are important for inserting details.
- # A backend trigger could have e.g. generated a primary key.
- if self.__detailLinkFlags:
- self.__requery (self.__detailLinkFlags.keys ())
-
- else:
- do._connection.update (do.table, self.__wherefields (), modifiedFields,
- recno)
-
- # The record is now "clean" again
- self._insertFlag = False
- self._updateFlag = False
- self._modifiedFlags = {}
- self._initialData = self._fields.copy ()
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r7303 - trunk/gnue-common/src/datasources/drivers/Base,
reinhard <=