[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
r5627 - trunk/gnue-common/src/datasources/drivers/Base
From: |
reinhard |
Subject: |
r5627 - trunk/gnue-common/src/datasources/drivers/Base |
Date: |
Sat, 3 Apr 2004 17:37:53 -0600 (CST) |
Author: reinhard
Date: 2004-04-03 17:37:51 -0600 (Sat, 03 Apr 2004)
New Revision: 5627
Modified:
trunk/gnue-common/src/datasources/drivers/Base/RecordSet.py
Log:
Added variant for dbdrivers to implement _postDelete, _postInsert, and
_postUpdate instead of _postChanges.
Modified: trunk/gnue-common/src/datasources/drivers/Base/RecordSet.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/Base/RecordSet.py 2004-04-03
17:52:21 UTC (rev 5626)
+++ trunk/gnue-common/src/datasources/drivers/Base/RecordSet.py 2004-04-03
23:37:51 UTC (rev 5627)
@@ -261,6 +261,66 @@
###
# Post any changes to database
- def _postChanges(self):
- return 1
+ def _postChanges (self):
+ """
+ Post any changes (deletes, inserts, and updates) to the database.
+ Descendants can either override this function, or the three functions
+ _postDelete, _postInsert, and _postUpdate.
+ _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.
+ """
+ if self._deleteFlag:
+ self._postDelete ()
+
+ elif self._insertFlag:
+ self._postInsert (self._fields)
+
+ elif self._updateFlag:
+ modifiedFields = {}
+ for field in (self._modifiedFlags.keys ()):
+ modifiedFields [field] = self._fields [field]
+ self._postUpdate (modifiedFields)
+ self._modifiedFlags = {}
+
+ self._deleteFlag = False
+ self._insertFlag = False
+ self._updateFlag = False
+
+ def _postDelete (self):
+ """
+ Post a deletion to the backend. Descendants should override this function
+ (or the general _postChanges function).
+
+ _postDelete is guaranteed to be only called for records that pend a
+ deletion.
+ """
+ pass
+
+ def _postInsert (self, fields):
+ """
+ Post an insert to the backend. Descendants should override this function
+ (or the general _postChanges function).
+
+ _postInsert is guaranteed to be only called for records that pend an
+ insert (i.e. that were newly created).
+
+ @param fields: a dictionary with field names as keys and field values as
+ values.
+ """
+ pass
+
+ def _postUpdate (self, fields):
+ """
+ Post an update to the backend. Descendants should override this function
+ (or the general _postChanges function).
+
+ _postUpdate is guaranteed to be only called for records that pend an
+ update (i.e. for existing records that were modified).
+
+ @param fields: a dictionary with field names as keys and field values as
+ values.
+ """
+ pass
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- r5627 - trunk/gnue-common/src/datasources/drivers/Base,
reinhard <=