Author: reinhard
Date: 2009-10-15 16:35:36 -0500 (Thu, 15 Oct 2009)
New Revision: 9973
Modified:
trunk/gnue-common/NEWS
trunk/gnue-common/src/datasources/GDataSource.py
trunk/gnue-common/src/datasources/drivers/Base/ResultSet.py
Log:
If the master moves to "no record" (index -1), set the resultset in detail
datasources/blocks to None. This situation might occur if the master is a
dropdown and the empty entry is selected there.
Modified: trunk/gnue-common/NEWS
===================================================================
--- trunk/gnue-common/NEWS 2009-10-15 21:32:44 UTC (rev 9972)
+++ trunk/gnue-common/NEWS 2009-10-15 21:35:36 UTC (rev 9973)
@@ -9,6 +9,7 @@
* [base] reworked implementation of "setup" and "version" modules
* [base] new function to search for configuration files
* [datasources] support for Python's builtin sqlite DBSIG2 module
+* [datasources] set detail resultset to None when master moves to "no record"
* Code cleanup
* Removed some unused modules
* Translation updates
Modified: trunk/gnue-common/src/datasources/GDataSource.py
===================================================================
--- trunk/gnue-common/src/datasources/GDataSource.py 2009-10-15 21:32:44 UTC (rev 9972)
+++ trunk/gnue-common/src/datasources/GDataSource.py 2009-10-15 21:35:36 UTC (rev 9973)
@@ -678,6 +678,22 @@
# ---------------------------------------------------------------------------
+ # Clear the current result set (meaning that the datasource will not have a
+ # current result set after this)
+ # ---------------------------------------------------------------------------
+
+ def clearResultSet (self):
+ """
+ Clear the current result set.
+
+ After this, the datasource will have no current result set, not even an
+ empty one.
+ """
+
+ self._activateResultSet (None)
+
+
+ # ---------------------------------------------------------------------------
# Create a new ResultSet object instance
# ---------------------------------------------------------------------------
@@ -739,8 +755,12 @@
self.__currentResultSet = resultSet
# Let our details follow
- if self.__currentResultSet.current is not None:
+ if self.__currentResultSet is not None \
+ and self.__currentResultSet.current is not None:
self.__currentResultSet.current._activate()
+ else:
+ for detail_ds in self.__details.keys():
+ detail_ds.clearResultSet()
self.__eventController.dispatchEvent ('dsResultSetActivated',
resultSet = resultSet)
Modified: trunk/gnue-common/src/datasources/drivers/Base/ResultSet.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/Base/ResultSet.py 2009-10-15 21:32:44 UTC (rev 9972)
+++ trunk/gnue-common/src/datasources/drivers/Base/ResultSet.py 2009-10-15 21:35:36 UTC (rev 9973)
@@ -910,13 +910,18 @@
# If the current record has *really* changed (this method can be called
# for non-changing records after requery or merge) to a new current
# record, bring all detail records in sync.
- if self.current and self.current != old_current:
- # If the cursor moved out of an empty record, throw it away.
- if old_current and old_current.isEmpty():
- if old_current in self.__cached_records:
- index = self.__cached_records.index(old_current)
- self.__remove_record(index)
- self.current._activate()
+ if self.current != old_current:
+ if self.current is not None:
+ if old_current and old_current.isEmpty():
+ # If the cursor moved out of an empty record, throw it away
+ if old_current in self.__cached_records:
+ index = self.__cached_records.index(old_current)
+ self.__remove_record(index)
+ self.current._activate()
+ else:
+ # Pointer moved to "no record": Create empty detail resultsets.
+ for detail_ds in self.__details.keys():
+ detail_ds.clearResultSet()
if send_event and self.__eventController is not None:
self.__eventController.dispatchEvent('dsCursorMoved')
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.