dabo Commit
Revision 6850
Date: 2011-09-20 05:19:10 -0700 (Tue, 20 Sep 2011)
Author: Jacekk
Trac: http://trac.dabodev.com/changeset/6850

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

Log:
- Finally, I decided to remove isAnyChanged() method call from isChanged.
This avoids false positives for all child cursors when only one grandchild 
cursor is changed.
The isAnyChanged method remains unchanged and is still fast but not so precise 
as isChanged.
- The appendDataSet method gains extended functionality and allows to update 
cursor internals: temporary key value and new flag.

Diff:
Modified: trunk/dabo/biz/dBizobj.py
===================================================================
--- trunk/dabo/biz/dBizobj.py   2011-09-19 19:55:06 UTC (rev 6849)
+++ trunk/dabo/biz/dBizobj.py   2011-09-20 12:19:10 UTC (rev 6850)
@@ -1493,10 +1493,24 @@
                return False
 
 
+       def _isAnyRowChanged(self, includeNewUnchanged):
+               """
+               For internal use only.
+               """
+               def _isThisChanged():
+                       self.exitScan = self.isChanged(includeNewUnchanged)
+                       return self.exitScan
+
+               ret = self.scan(_isThisChanged, scanRequeryChildren=False)
+               return bool(ret)
+
+
        def isChanged(self, includeNewUnchanged=None, withChildren=True):
                """
                Return True if data has changed in this bizobj and any children.
 
+               It's more precise than isAnyChanged() method bacuse it checks 
every node
+               in branch, but it generates more overhead.
                By default, only the current record is checked. Call 
isAnyChanged() to
                check all records.
                """
@@ -1515,7 +1529,9 @@
 
                if not ret and withChildren:
                        for child in self.getChildren():
-                               ret = 
child.isAnyChanged(includeNewUnchanged=includeNewUnchanged)
+                               # Since isChanged is more precise than 
isAnyChanged, to avoid false
+                               # positives from all cursors, we can't use it 
internally.
+                               ret = 
child._isAnyRowChanged(includeNewUnchanged)
                                if ret:
                                        break
                return ret
@@ -1887,14 +1903,14 @@
                return ret
 
 
-       def appendDataSet(self, ds):
+       def appendDataSet(self, ds, updateInternals=False):
                """
                Appends the rows in the passed dataset to this bizobj's 
dataset. No checking
                is done on the dataset columns to make sure that they are 
correct for this bizobj;
                it is the responsibility of the caller to make sure that they 
match. If invalid data is
                passed, a dException.FieldNotFoundException will be raised.
                """
-               self._CurrentCursor.appendDataSet(ds)
+               self._CurrentCursor.appendDataSet(ds, 
updateInternals=updateInternals)
 
 
        def cloneRecord(self):

Modified: trunk/dabo/db/dCursorMixin.py
===================================================================
--- trunk/dabo/db/dCursorMixin.py       2011-09-19 19:55:06 UTC (rev 6849)
+++ trunk/dabo/db/dCursorMixin.py       2011-09-20 12:19:10 UTC (rev 6850)
@@ -1367,7 +1367,7 @@
                return dDataSet(ds)
 
 
-       def appendDataSet(self, ds):
+       def appendDataSet(self, ds, updateInternals=False):
                """
                Appends the rows in the passed dataset to this cursor's 
dataset. No checking
                is done on the dataset columns to make sure that they are 
correct for this cursor;
@@ -1380,6 +1380,9 @@
                autoPopulatePK = self.AutoPopulatePK
                for rec in ds:
                        self.new()
+                       if updateInternals:
+                               self.genTempAutoPK()
+                               self.setNewFlag()
                        for col, val in rec.items():
                                if autoPopulatePK and (col in kf):
                                        continue



_______________________________________________
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