dabo Commit
Revision 6227
Date: 2010-11-29 10:41:16 -0800 (Mon, 29 Nov 2010)
Author: Paul
Trac: http://trac.dabodev.com/changeset/6227
Changed:
U trunk/dabo/biz/dBizobj.py
U trunk/dabo/ui/uiwx/dForm.py
Log:
Removed the recently-added force argument from requeryAllChildren,
in favor of adding a note to the docstring that developers should
explicitly call self.expireCache() before requerying, which ensures
all cursors (not just the current one) in a bizobj will get requeried
next time the record becomes active.
Moved the setCurrentParent() call outside the check for RequeryWithParent,
as the setting of the parent should happen unconditionally. However,
this will result in the side-effect of an implicit requery() if the
cursor for that key doesn't exist yet, *and* RequeryOnLoad is True.
Refactored cacheExpired() a bit, with a check for lastRequeryTime being
None.
Added biz.expireCache() to dForm.requery() per Jacek's suggestion.
Diff:
Modified: trunk/dabo/biz/dBizobj.py
===================================================================
--- trunk/dabo/biz/dBizobj.py 2010-11-29 00:49:13 UTC (rev 6226)
+++ trunk/dabo/biz/dBizobj.py 2010-11-29 18:41:16 UTC (rev 6227)
@@ -1514,7 +1514,7 @@
return ret
- def requeryAllChildren(self, force=False):
+ def requeryAllChildren(self):
""" Requery each child bizobj's data set.
Called to assure that all child bizobjs have had their data sets
@@ -1522,8 +1522,10 @@
automatically when appropriate, but user code may call this as
well
if needed.
- If force is True, the child will be requeried even if
ChildCacheInterval
- hasn't expired yet.
+ Note: children will only be requeried if their cache hasn't
expired
+ yet. If you want to force all children to requery at the next
opportunity,
+ you should call self.expireCache() before calling
self.requery() or
+ self.requeryAllChildren().
"""
if not self.__children:
return True
@@ -1532,24 +1534,25 @@
if errMsg:
raise dException.BusinessRuleViolation(errMsg)
+
for child in self.__children:
# Let the child know the current dependent PK
+ child.setCurrentParent() ##pkm: moved from the block
below: should be unconditional
if child.RequeryWithParent:
- child.setCurrentParent() ##pkm: shouldn't this
happen unconditionally?
if not
child.isAnyChanged(useCurrentParent=True):
# Check for caching
- if force or not
child._CurrentCursor.lastRequeryTime or child.cacheExpired():
+ if child._CurrentCursor.lastRequeryTime
or child.cacheExpired():
child.requery()
self.afterChildRequery()
def cacheExpired(self):
"""This controls if a child requery is needed when a parent is
requeried."""
- ret = True
if self._childCacheInterval:
last = self._CurrentCursor.lastRequeryTime
- ret = ((time.time() - last) > self._childCacheInterval)
- return ret
+ if last:
+ return ((time.time() - last) >
self._childCacheInterval)
+ return True
def expireCache(self, recurse=True, _allCursors=False):
Modified: trunk/dabo/ui/uiwx/dForm.py
===================================================================
--- trunk/dabo/ui/uiwx/dForm.py 2010-11-29 00:49:13 UTC (rev 6226)
+++ trunk/dabo/ui/uiwx/dForm.py 2010-11-29 18:41:16 UTC (rev 6227)
@@ -473,6 +473,9 @@
# A False from confirmChanges means "don't proceed"
return
+ ## A user-initiated requery should expire the cache on child
bizobjs too:
+ bizobj.expireCache()
+
try:
self.StatusText = _("Please wait... requerying
dataset...")
# busy = dabo.ui.busyInfo(_("Please wait... requerying
dataset..."))
_______________________________________________
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]