commit-gnue
[Top][All Lists]
Advanced

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

[gnue] r7369 - in trunk: gnue-common/src/datasources gnue-common/src/dat


From: reinhard
Subject: [gnue] r7369 - in trunk: gnue-common/src/datasources gnue-common/src/datasources/drivers/Base gnue-forms/src/GFObjects
Date: Thu, 14 Apr 2005 18:06:43 -0500 (CDT)

Author: reinhard
Date: 2005-04-14 18:06:42 -0500 (Thu, 14 Apr 2005)
New Revision: 7369

Modified:
   trunk/gnue-common/src/datasources/GDataSource.py
   trunk/gnue-common/src/datasources/drivers/Base/RecordSet.py
   trunk/gnue-forms/src/GFObjects/GFBlock.py
Log:
Added postAll and requeryAll to the DataSource.


Modified: trunk/gnue-common/src/datasources/GDataSource.py
===================================================================
--- trunk/gnue-common/src/datasources/GDataSource.py    2005-04-14 18:49:06 UTC 
(rev 7368)
+++ trunk/gnue-common/src/datasources/GDataSource.py    2005-04-14 23:06:42 UTC 
(rev 7369)
@@ -68,6 +68,9 @@
     self._topObject = None
     self.sorting = None
 
+    # The master DataSource object
+    self.__master = None
+
     #
     # trigger support
     #
@@ -182,6 +185,7 @@
   def deleteCurrentRecordsetEntry(self):
     self._currentResultSet.getPostingRecordset().delete()
 
+
   # ---------------------------------------------------------------------------
   # Sync the current record with the backend
   # ---------------------------------------------------------------------------
@@ -192,9 +196,10 @@
     by the backend.
     """
 
-    if self._currentResultSet and self._currentResultSet.current:
-      self._currentResultSet.current.sync ()
+    self.postAll ()
+    self.requeryAll ()
 
+
   # ---------------------------------------------------------------------------
   # Call a backend function for the current record
   # ---------------------------------------------------------------------------
@@ -204,9 +209,52 @@
     Call function in the backend for the current record.
     """
 
-    if self._currentResultSet and self._currentResultSet.current:
-      self._currentResultSet.current.call (name, params)
+    self.postAll ()
+    result = self._currentResultSet.current.call (name, params)
+    self.requeryAll ()
+    return result
 
+
+  # ---------------------------------------------------------------------------
+  # Post all changes in this datasource to the backend
+  # ---------------------------------------------------------------------------
+
+  def postAll (self):
+    """
+    Post all changes to the backend.
+
+    This function posts the top level master datasource of this datasource and
+    all of that datasource's children.
+
+    After calling postAll, L{requeryAll} must be called.
+    """
+
+    if self.__master:
+      self.__master.postAll ()
+    else:
+      self._currentResultSet.post ()
+
+
+  # ---------------------------------------------------------------------------
+  # Requery data from the backend
+  # ---------------------------------------------------------------------------
+
+  def requeryAll (self):
+    """
+    Requery data from the backend.
+
+    This must be called after L{postAll} to synchronize the datasource with
+    changes that happened in the backend (through backend triggers). It
+    requeries the top level master datasource of this datasource and all of
+    that datasource's children.
+    """
+
+    if self.__master:
+      self.__master.requeryAll ()
+    else:
+      self._currentResultSet.requery ()
+
+
   #
   # get/set the static condition assosiated with a datasource
   # the static condition is build out of the <condition> child
@@ -424,9 +472,10 @@
                  % (self.name, self.master))
 
       if self._topObject._datasourceDictionary.has_key(self.master):
-        self._topObject._datasourceDictionary[self.master] \
-            .getDataObject().addDetailDataObject(self.getDataObject(),
-                                                 self)
+        self.__master = self._topObject._datasourceDictionary [self.master]
+        masterDataObject = self.__master.getDataObject ()
+        detailDataObject = self.getDataObject ()
+        masterDataObject.addDetailDataObject (detailDataObject, self)
       else:
         tmsg = u_("Detail source '%(source)s' references non-existant master "
                   "'%(master)s'") \

Modified: trunk/gnue-common/src/datasources/drivers/Base/RecordSet.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/Base/RecordSet.py 2005-04-14 
18:49:06 UTC (rev 7368)
+++ trunk/gnue-common/src/datasources/drivers/Base/RecordSet.py 2005-04-14 
23:06:42 UTC (rev 7369)
@@ -470,49 +470,6 @@
 
 
   # ---------------------------------------------------------------------------
-  # Post and requery the top level master record
-  # ---------------------------------------------------------------------------
-
-  def __post_master (self):
-
-    if self.__masterRecord:
-      self.__masterRecord.__post_master ()
-    else:
-      self.post ()
-
-  # ---------------------------------------------------------------------------
-
-  def __requery_master (self):
-
-    if self.__masterRecord:
-      self.__masterRecord.__requery_master ()
-    else:
-      self.requery ()
-
-
-  # ---------------------------------------------------------------------------
-  # Sync backend with frontend
-  # ---------------------------------------------------------------------------
-
-  def sync (self):
-    """
-    Write all local changes of the top level master of this record and all of
-    that's details to the backend, and upate the local cache with changes done
-    by the backend.
-
-    This method can be called to make sure that the backend is up to date with
-    the current state of the data. This makes sense for example before calling
-    some code running in the backend that would need that data (appserver
-    procedures or stored procedures for SQL databases) or when the backend is
-    expected to do some magic on receiving data (like running triggers and
-    recalculating calculated fields).
-    """
-
-    self.__post_master ()
-    self.__requery_master ()
-
-
-  # ---------------------------------------------------------------------------
   # Call backend code
   # ---------------------------------------------------------------------------
 
@@ -520,6 +477,10 @@
     """
     Call a function of the backend.
 
+    It is highly recommended to post this record, it's chain of master records
+    and all of it's details before calling this function, so the backend is up
+    to date when executing the called backend method.
+
     @param methodname: Name of the function to call.
     @param parameters: Dictionary with parametername/value pairs.
     @return: Return value of the function that was called.
@@ -528,11 +489,8 @@
     if self.isEmpty ():
       raise errors.ApplicationError, u_("Function call on empty record")
 
-    self.__post_master ()
-    result = self.__connection.call (self.__tablename, self.__wherefields (),
+    return self.__connection.call (self.__tablename, self.__wherefields (),
         methodname, parameters)
-    self.__requery_master ()
-    return result
 
 
   # ---------------------------------------------------------------------------

Modified: trunk/gnue-forms/src/GFObjects/GFBlock.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFBlock.py   2005-04-14 18:49:06 UTC (rev 
7368)
+++ trunk/gnue-forms/src/GFObjects/GFBlock.py   2005-04-14 23:06:42 UTC (rev 
7369)
@@ -515,8 +515,8 @@
 
     self._resultSet.setRecord(self._precommitRecord)
 
-    if not self._dataSourceLink.hasMaster():
-      self._resultSet.post()
+    if not self._dataSourceLink.hasMaster ():
+      self._dataSourceLink.postAll ()
 
   #
   # Called after the commit on the backend is through.
@@ -531,8 +531,8 @@
       self.newRecord()
 
     # Synchronize backend -> resultset -> UI
-    if not self._dataSourceLink.hasMaster():
-      self._resultSet.requery()
+    if not self._dataSourceLink.hasMaster ():
+      self._dataSourceLink.requeryAll ()
 
     self.mode='normal'
 





reply via email to

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