[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r7826 - in trunk: gnue-common/src/datasources gnue-common/src/dat
From: |
reinhard |
Subject: |
[gnue] r7826 - in trunk: gnue-common/src/datasources gnue-common/src/datasources/drivers/Base gnue-forms/src/GFObjects |
Date: |
Fri, 12 Aug 2005 07:44:06 -0500 (CDT) |
Author: reinhard
Date: 2005-08-12 07:44:05 -0500 (Fri, 12 Aug 2005)
New Revision: 7826
Modified:
trunk/gnue-common/src/datasources/GDataSource.py
trunk/gnue-common/src/datasources/drivers/Base/RecordSet.py
trunk/gnue-common/src/datasources/drivers/Base/ResultSet.py
trunk/gnue-forms/src/GFObjects/GFBlock.py
Log:
If the transaction hasn't been committed before requerying, requery a second
time after the next commit, because the commit can also change data (e.g. in an
appserver OnValidate trigger).
Modified: trunk/gnue-common/src/datasources/GDataSource.py
===================================================================
--- trunk/gnue-common/src/datasources/GDataSource.py 2005-08-11 13:20:19 UTC
(rev 7825)
+++ trunk/gnue-common/src/datasources/GDataSource.py 2005-08-12 12:44:05 UTC
(rev 7826)
@@ -190,7 +190,7 @@
if self._connection._need_rollback_after_exception_:
raise Exceptions.FunctionNotAvailableError
self.postAll ()
- self.requeryAll ()
+ self.requeryAll (commit = False)
# ---------------------------------------------------------------------------
@@ -208,7 +208,7 @@
raise Exceptions.FunctionNotAvailable
self.postAll ()
result = self.__currentResultSet.current.call (name, params)
- self.requeryAll ()
+ self.requeryAll (commit = False)
return result
# ---------------------------------------------------------------------------
@@ -741,7 +741,7 @@
# Requery data from the backend
# ---------------------------------------------------------------------------
- def requeryAll (self):
+ def requeryAll (self, commit = True):
"""
Requery data from the backend.
@@ -749,12 +749,15 @@
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.
+
+ @param commit: indicate whether a commit was done since the call to
+ L{postAll}.
"""
if self.__master:
- self.__master.requeryAll ()
+ self.__master.requeryAll (commit = commit)
else:
- self.__currentResultSet.requery ()
+ self.__currentResultSet.requery (commit = commit)
# ---------------------------------------------------------------------------
Modified: trunk/gnue-common/src/datasources/drivers/Base/RecordSet.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/Base/RecordSet.py 2005-08-11
13:20:19 UTC (rev 7825)
+++ trunk/gnue-common/src/datasources/drivers/Base/RecordSet.py 2005-08-12
12:44:05 UTC (rev 7826)
@@ -161,8 +161,12 @@
# represents the committed state of the backend.
self.__initialData = initialData.copy () # don't touch the parameter!
- # Set to true if the changes in this record have been posted
- self.__posted = False
+ # Requery status:
+ # None = no requery necessary
+ # 'posted' = record has been posted, requery necessary
+ # 'commit' = record has been requeried after the last post but needs to be
+ # requeried again after the following commit
+ self.__requeryStatus = None
if self.__initialData:
@@ -471,12 +475,13 @@
# ---------------------------------------------------------------------------
- def _isPosted (self):
+ def _needsRequery (self, commit):
"""
Return True if this record has been successfully posted to the backend with
L{_post}.
"""
- return self.__posted
+ return (self.__requeryStatus == 'posted') \
+ or (self.__requeryStatus == 'commit' and commit)
# ---------------------------------------------------------------------------
@@ -495,12 +500,12 @@
self.__initialData.update (data)
- if self.__posted:
+ if self.__requeryStatus == 'posted':
# record has been written to the backend - everything is clean now
self.__fields.update (data)
self.__status = 'clean'
- self.__posted = False
self.__modifiedFlags = {}
+ self.__requeryStatus = None
elif self.__status == 'clean':
# record is clean anyway
@@ -617,7 +622,8 @@
self.__connection.update (self.__tablename, self.__wherefields (),
modifiedFields)
- self.__posted = True
+ # Record needs a requery now
+ self.__requeryStatus = 'posted'
# Post all detail records
for (dataSource, resultSet) in (self.__cachedDetailResultSets.items ()):
@@ -631,22 +637,29 @@
# Requery the record data from the backend
# ---------------------------------------------------------------------------
- def _requery (self):
+ def _requery (self, commit):
"""
Requery this record to reflect changes done by the backend.
This is called by L{ResultSet.requery} for each record that has been posted
in the last L{ResultSet.post} call.
+
+ @param commit: True if a commit happened since the L{_post} call. If no
+ commit has happened, the record will be requeried again after the
+ following commit.
"""
- if not self.__posted:
+ if self.__requeryStatus is None:
return
# The record is now "clean" again
self.__status = 'clean'
- self.__posted = False
self.__modifiedFlags = {}
self.__initialData = self.__fields.copy ()
+ if commit:
+ self.__requeryStatus = None
+ else:
+ self.__requeryStatus = 'commit'
# First, requery ourselves
if self.__requery:
Modified: trunk/gnue-common/src/datasources/drivers/Base/ResultSet.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/Base/ResultSet.py 2005-08-11
13:20:19 UTC (rev 7825)
+++ trunk/gnue-common/src/datasources/drivers/Base/ResultSet.py 2005-08-12
12:44:05 UTC (rev 7826)
@@ -673,7 +673,7 @@
# Sync resultset with backend, and sync listeners with resultset
# ---------------------------------------------------------------------------
- def requery (self):
+ def requery (self, commit = True):
"""
Synchronize everything after a call to L{post}.
@@ -688,12 +688,12 @@
index = 0
while index < len (self.__cachedRecords):
record = self.__cachedRecords [index]
- if record._isPosted ():
+ if record._needsRequery (commit):
if ((record.isEmpty () or record.isDeleted ()) \
and self.__connection is not None):
self.__removeRecord (index)
else:
- record._requery ()
+ record._requery (commit)
index += 1
else:
index += 1
Modified: trunk/gnue-forms/src/GFObjects/GFBlock.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFBlock.py 2005-08-11 13:20:19 UTC (rev
7825)
+++ trunk/gnue-forms/src/GFObjects/GFBlock.py 2005-08-12 12:44:05 UTC (rev
7826)
@@ -543,7 +543,7 @@
# Synchronize backend -> resultset -> UI
if self._getMasterBlock () is None:
- self._dataSourceLink.requeryAll ()
+ self._dataSourceLink.requeryAll (commit = True)
# Our recordCount might have changed if records were deleted
self._recordCount = self._resultSet.getRecordCount()
@@ -694,7 +694,7 @@
try:
self._dataSourceLink.postAll ()
res = self._resultSet.current.call (name, parameters)
- self._dataSourceLink.requeryAll ()
+ self._dataSourceLink.requeryAll (commit = False)
finally:
self.switchRecord (0)
@@ -708,7 +708,7 @@
def updateCurrentRecordSet (self):
try:
self._dataSourceLink.postAll ()
- self._dataSourceLink.requeryAll ()
+ self._dataSourceLink.requeryAll (commit = False)
finally:
self.switchRecord (0)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r7826 - in trunk: gnue-common/src/datasources gnue-common/src/datasources/drivers/Base gnue-forms/src/GFObjects,
reinhard <=