dabo Commit
Revision 6917
Date: 2011-10-25 18:21:45 -0700 (Tue, 25 Oct 2011)
Author: Paul
Trac: http://trac.dabodev.com/changeset/6917
Changed:
U trunk/dabo/biz/dBizobj.py
Log:
Consolidated redundant code between requeryAllChildren() and
_updateChildrenParent().
Please review the comments in _updateChildrenParent() - we were checking
different
conditions before depending on whether we got to the child requery code via a
navigation like first(), or an explicit setting of the row number.
Diff:
Modified: trunk/dabo/biz/dBizobj.py
===================================================================
--- trunk/dabo/biz/dBizobj.py 2011-10-26 01:17:01 UTC (rev 6916)
+++ trunk/dabo/biz/dBizobj.py 2011-10-26 01:21:45 UTC (rev 6917)
@@ -1418,9 +1418,17 @@
"""
if updateChildren is not None:
for child in self._children:
- # Let the child update to the current record.
+ # Let the child update to the current record:
child.setCurrentParent()
- if updateChildren and child.RowCount == 0 and
child.cacheExpired():
+ # consolidation note: 1) requeryAllChildren()
checked for child.isAnyChanged(useCurrentParent=True);
+ # 2) _resetChildrenParent
instead checked for child.RowCount == 0
+ # I think both are wrong. In #1, you'd never
get a requery of that child if there was
+ # one changed record in the hierarchy, plus
there are performance issues in running
+ # that check. In #2, you'd never get a child
requery unless RowCount was 0. I'm leaving
+ # both of those conditions out completely for
now, although that is most certainly
+ # wrong as well, but at least we are now
consistent in behavior between e.g. self.first()
+ # and self.RowNumber = 0.
+ if updateChildren and child.cacheExpired():
child.requery()
@@ -1727,7 +1735,7 @@
return ret
- def requeryAllChildren(self):
+ def requeryAllChildren(self, _doRequery=True):
"""
Requery each child bizobj's data set.
@@ -1748,18 +1756,11 @@
if errMsg:
raise dException.BusinessRuleViolation(errMsg)
+ self._resetChildrenParent(_doRequery)
+ if _doRequery:
+ self.afterChildRequery()
- 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:
- if not
child.isAnyChanged(useCurrentParent=True):
- # Check for caching
- if child.cacheExpired():
- child.requery()
- self.afterChildRequery()
-
def cacheExpired(self):
"""This controls if a child requery is needed when a parent is
requeried."""
if self._childCacheInterval:
_______________________________________________
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]