commit-gnue
[Top][All Lists]
Advanced

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

[gnue] r7368 - in trunk: gnue-common/src/datasources/drivers/Base gnue-f


From: reinhard
Subject: [gnue] r7368 - in trunk: gnue-common/src/datasources/drivers/Base gnue-forms/src
Date: Thu, 14 Apr 2005 13:49:07 -0500 (CDT)

Author: reinhard
Date: 2005-04-14 13:49:06 -0500 (Thu, 14 Apr 2005)
New Revision: 7368

Modified:
   trunk/gnue-common/src/datasources/drivers/Base/Connection.py
   trunk/gnue-forms/src/GFForm.py
Log:
Keep the status of the form as unsaved if changes have been posted to the
backend but not yet committed. This can happen when update() or call() is
called for a block.


Modified: trunk/gnue-common/src/datasources/drivers/Base/Connection.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/Base/Connection.py        
2005-04-14 18:26:41 UTC (rev 7367)
+++ trunk/gnue-common/src/datasources/drivers/Base/Connection.py        
2005-04-14 18:49:06 UTC (rev 7368)
@@ -73,6 +73,7 @@
     self.manager = connections
     self.name = name
     self.parameters = parameters
+    self.__pending = False
 
 
   # ---------------------------------------------------------------------------
@@ -97,6 +98,7 @@
     gEnter (8)
     return gLeave (8, self._getLoginFields ())
 
+
   # ---------------------------------------------------------------------------
   # Connect to the backend
   # ---------------------------------------------------------------------------
@@ -114,6 +116,7 @@
     self._beginTransaction ()
     gLeave (8)
 
+
   # ---------------------------------------------------------------------------
   # Initialize a new record with default data
   # ---------------------------------------------------------------------------
@@ -129,6 +132,7 @@
     gEnter (8)
     return gLeave (8, self._initialize (table))
 
+
   # ---------------------------------------------------------------------------
   # Insert a new record in the backend
   # ---------------------------------------------------------------------------
@@ -145,8 +149,11 @@
     """
 
     gEnter (8)
-    return gLeave (8, self._insert (table, newfields, recno))
+    rowid = self._insert (table, newfields, recno)
+    self.__pending = True
+    return gLeave (8, rowid)
 
+
   # ---------------------------------------------------------------------------
   # Update an existing record in the backend
   # ---------------------------------------------------------------------------
@@ -164,8 +171,10 @@
 
     gEnter (8)
     self._update (table, oldfields, newfields, recno)
+    self.__pending = True
     gLeave (8)
 
+
   # ---------------------------------------------------------------------------
   # Delete a record from the backend
   # ---------------------------------------------------------------------------
@@ -182,8 +191,10 @@
 
     gEnter (8)
     self._delete (table, oldfields, recno)
+    self.__pending = True
     gLeave (8)
 
+
   # ---------------------------------------------------------------------------
   # Requery an existing record to reflect changes done by the backend
   # ---------------------------------------------------------------------------
@@ -202,6 +213,7 @@
     gEnter (8)
     return gLeave (8, self._requery (table, oldfields, fields))
 
+
   # ---------------------------------------------------------------------------
   # Call a backend function
   # ---------------------------------------------------------------------------
@@ -218,10 +230,29 @@
     @param recno: Record number to be used in error messages.
     @return: Result of the function that was called.
     """
+
     gEnter (8)
-    return gLeave (8, self._call (table, oldfields, methodname, parameters))
+    result = self._call (table, oldfields, methodname, parameters)
+    self.__pending = True
+    return gLeave (8, result)
 
+
   # ---------------------------------------------------------------------------
+  # Check if the connection has posted but not yet committed changes
+  # ---------------------------------------------------------------------------
+
+  def isPending (self):
+    """
+    Check whether there are changes that have been posted (via L{insert},
+    L{update}, or L{delete}) but not yet committed.
+
+    @return: True if there are pending changes.
+    """
+
+    return self.__pending
+
+
+  # ---------------------------------------------------------------------------
   # Commit pending changes in the backend
   # ---------------------------------------------------------------------------
 
@@ -232,9 +263,11 @@
 
     gEnter (8)
     self._commit ()
+    self.__pending = False
     self._beginTransaction ()
     gLeave (8)
 
+
   # ---------------------------------------------------------------------------
   # Undo any uncommitted changes in the backend
   # ---------------------------------------------------------------------------
@@ -246,9 +279,11 @@
 
     gEnter (8)
     self._rollback ()
+    self.__pending = False
     self._beginTransaction ()
     gLeave (8)
 
+
   # ---------------------------------------------------------------------------
   # Close the connection to the backend
   # ---------------------------------------------------------------------------

Modified: trunk/gnue-forms/src/GFForm.py
===================================================================
--- trunk/gnue-forms/src/GFForm.py      2005-04-14 18:26:41 UTC (rev 7367)
+++ trunk/gnue-forms/src/GFForm.py      2005-04-14 18:49:06 UTC (rev 7368)
@@ -481,14 +481,25 @@
     Checks all block in the form whether they are saved (committed) or not.
     @return: boolean, True if all the blocks are committed.
     """
+
+    # Is the current entry changed?
+    # FIXME: should only cause the form to appear unsaved if the entry is bound
+    # to a field.
     if (self._currentEntry._type != 'GFButton' and \
         self._currentEntry._displayHandler.isPending()):
       return False
 
+    # Are there any not yet posted changes in any of the blocks?
     for block in self._logic._blockList:
       if not block.isSaved():
         return False
 
+    # Does a connection have any pending (already posted but not yet committed)
+    # changes?
+    for connection in (self.__getConnections ()).values ():
+      if connection.isPending ():
+        return False
+
     return True
 
 





reply via email to

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