dabo Commit
Revision 6182
Date: 2010-11-06 09:56:31 -0700 (Sat, 06 Nov 2010)
Author: Paul
Trac: http://trac.dabodev.com/changeset/6182

Changed:
U   trunk/dabo/biz/dBizobj.py

Log:
I'm starting to experiment with biz.cacheExpired(). I'm overriding that method
instead of using ChildCacheInterval, because I have some rules in place to
determine if the cache is expired or not, that actually don't involve amount
of time since last requery. 

Sometimes in my code I explicitly call biz.requeryAllChildren(), and the 
children weren't requerying because of code in my overridden cacheExpired().

So, I added a force arg to requeryAllChildren(), default False, so that when
my code explicitly calls requeryAllChildren(), it can send force=True to make
sure the children get requeried.

I also annotated a setCurrentParent() call that I believe should happen
unconditionally but I didn't want to make the change without Ed's blessing
because there could be a good reason for it being the way it is that I just
don't see at the moment.



Diff:
Modified: trunk/dabo/biz/dBizobj.py
===================================================================
--- trunk/dabo/biz/dBizobj.py   2010-11-03 22:31:03 UTC (rev 6181)
+++ trunk/dabo/biz/dBizobj.py   2010-11-06 16:56:31 UTC (rev 6182)
@@ -1475,6 +1475,7 @@
                """ Lets dependent child bizobjs update to the current parent
                record.
                """
+               _oldKey = self.__currentCursorKey
                if self.LinkField:
                        if val is None:
                                val = self.getParentLinkValue()
@@ -1482,9 +1483,10 @@
                        self.__currentCursorKey = val
                        # Make sure there is a cursor object for this key.
                        self._CurrentCursor = val
-                       # Propagate the change to any children:
-                       for child in self.__children:
-                               child.setCurrentParent()
+                       if _oldKey != val:
+                               # Propagate the change to any children:
+                               for child in self.__children:
+                                       child.setCurrentParent()
 
 
        def addChild(self, child):
@@ -1512,13 +1514,16 @@
                return ret
 
 
-       def requeryAllChildren(self):
+       def requeryAllChildren(self, force=False):
                """ Requery each child bizobj's data set.
 
                Called to assure that all child bizobjs have had their data sets
                refreshed to match the current master row. This will normally 
happen
                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.
                """
                if not self.__children:
                        return True
@@ -1530,10 +1535,10 @@
                for child in self.__children:
                        # Let the child know the current dependent PK
                        if child.RequeryWithParent:
-                               child.setCurrentParent()
+                               child.setCurrentParent()  ##pkm: shouldn't this 
happen unconditionally?
                                if not 
child.isAnyChanged(useCurrentParent=True):
                                        # Check for caching
-                                       if child.cacheExpired():
+                                       if force or child.cacheExpired():
                                                child.requery()
                self.afterChildRequery()
 



_______________________________________________
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]

Reply via email to