commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnue] r7175 - trunk/gnue-common/src/datasources/drivers/Base


From: reinhard
Subject: [gnue] r7175 - trunk/gnue-common/src/datasources/drivers/Base
Date: Fri, 11 Mar 2005 13:47:20 -0600 (CST)

Author: reinhard
Date: 2005-03-11 13:47:19 -0600 (Fri, 11 Mar 2005)
New Revision: 7175

Modified:
   trunk/gnue-common/src/datasources/drivers/Base/RecordSet.py
Log:
Requery a record after posting it to the backend.


Modified: trunk/gnue-common/src/datasources/drivers/Base/RecordSet.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/Base/RecordSet.py 2005-03-11 
19:43:53 UTC (rev 7174)
+++ trunk/gnue-common/src/datasources/drivers/Base/RecordSet.py 2005-03-11 
19:47:19 UTC (rev 7175)
@@ -269,6 +269,24 @@
 
 
   # ---------------------------------------------------------------------------
+  # Requery the record data from the backend
+  # ---------------------------------------------------------------------------
+
+  def __requery (self):
+    """
+    Requery this record to reflect changes done by the backend.
+
+    This method may not be called if the record has unsaved changes; they would
+    get lost!
+    """
+    do = self._parent._dataObject
+    newfields = do._connection.requery (do.table, self.__wherefields (),
+                                        self._fields.keys ())
+    self._initialData.update (newfields)
+    self._fields.update (newfields)
+
+
+  # ---------------------------------------------------------------------------
   # Post changes to database
   # ---------------------------------------------------------------------------
 
@@ -279,6 +297,11 @@
 
     @param recordNumber: Record number to be used in error messages.
     """
+
+    # Just to make sure - you never know who calls us...
+    if not self.isPending ():
+      return
+
     # Should a post() to a read only datasource cause a ReadOnlyError?
     # It does no harm to attempt to post since nothing will be posted,
     # But does this allow sloppy programming?
@@ -290,8 +313,7 @@
     status = (self._insertFlag, self._deleteFlag, self._updateFlag)
 
     # Call the hooks for commit-level hooks
-    if not self.isEmpty() and hasattr(self._parent._dataObject,'_dataSource'):
-
+    if hasattr(self._parent._dataObject,'_dataSource'):
       if self._insertFlag and not self._deleteFlag:
         self._parent._dataObject._dataSource._beforeCommitInsert(self)
       elif self._deleteFlag and not self._insertFlag:
@@ -322,9 +344,8 @@
             raise exceptions.InvalidDatasourceDefintion, \
                 errors.getException () [2]
 
-    if self.isPending():
-      gDebug (8, 'Posting datasource %s' % self._parent._dataObject.name)
-      self._postChanges (recordNumber)
+    gDebug (8, 'Posting datasource %s' % self._parent._dataObject.name)
+    self._postChanges (recordNumber)
 
     # Post all detail records
     for child in (self._cachedDetailResultSets.values ()):
@@ -336,7 +357,11 @@
 
       child.post (foreign_keys = fk)
 
+    # Now, requery, as the posting of the record and/or of the details could
+    # have changed something
+    self.__requery ()
 
+
   # ---------------------------------------------------------------------------
   # Sets the ResultSet associated with this master record
   # ---------------------------------------------------------------------------





reply via email to

[Prev in Thread] Current Thread [Next in Thread]