dabo Commit
Revision 6189
Date: 2010-11-11 15:34:16 -0800 (Thu, 11 Nov 2010)
Author: Paul
Trac: http://trac.dabodev.com/changeset/6189
Changed:
U trunk/dabo/biz/dBizobj.py
U trunk/dabo/db/dCursorMixin.py
Log:
Added biz.expireCache(), which will ensure child records will requery
during the next cycle.
Diff:
Modified: trunk/dabo/biz/dBizobj.py
===================================================================
--- trunk/dabo/biz/dBizobj.py 2010-11-11 21:13:02 UTC (rev 6188)
+++ trunk/dabo/biz/dBizobj.py 2010-11-11 23:34:16 UTC (rev 6189)
@@ -1552,6 +1552,27 @@
return ret
+ def expireCache(self, recurse=True, _allCursors=False):
+ """Expire the requery cache so that a subsequent
self.Parent.requeryAllChildren()
+ will fetch records from the backend instead of using the cached
records.
+
+ If recurse is True, the cache in the child bizobjs will be
expired, too.
+ """
+ if _allCursors:
+ cursors = self.__cursors.values()
+ else:
+ cursors = [self._CurrentCursor]
+
+ for cursor in cursors:
+ cursor.clearLastRequeryTime()
+
+ if recurse:
+ for child in self.__children:
+ ## unconditionally set _allCursors=True for
recursed child bizobjs, to make sure
+ ## all cursors will get requeried next time,
not just the _CurrentCursor.
+ child.expireCache(_allCursors=True)
+
+
def getPK(self):
""" Return the value of the PK field."""
if self.KeyField is None:
Modified: trunk/dabo/db/dCursorMixin.py
===================================================================
--- trunk/dabo/db/dCursorMixin.py 2010-11-11 21:13:02 UTC (rev 6188)
+++ trunk/dabo/db/dCursorMixin.py 2010-11-11 23:34:16 UTC (rev 6189)
@@ -66,7 +66,7 @@
# Holds the last SQL run in a requery() call.
self._lastSQL = ""
# Hold the time that this cursor was last requeried.
- self.lastRequeryTime = 0
+ self.clearLastRequeryTime()
# These are used to determine if the field list of successive
select statements
# are identical.
self.__lastExecute = ""
@@ -137,6 +137,11 @@
self.initProperties()
+ def clearLastRequeryTime(self):
+ """Clear the last requery time to force the cache to be
expired."""
+ self.lastRequeryTime = 0
+
+
def setCursorFactory(self, func, cls):
self._cursorFactoryFunc = func
self._cursorFactoryClass = cls
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message:
http://leafe.com/archives/byMID/[email protected]