On 10/27/11 2:53 PM, Jacek Kałucki wrote:
> Użytkownik Paul McNett napisał:
>> >  Failure to reset self.exitScan to False results in all future scans 
>> > exiting
>> >  immediately, so for instance calling getChangedRows() on a biz with 3
>> >  records and children would return all rows as having changes after the 
>> > first
>> >  row with changes was found. I'll hand it to you that it made it fast!:)
> Sorry, but I can't observe such behaviour in my code, I mean that
> the getChangedRows() always returns correct list of changed rows.
> Don't know how it can work in differ way for you.
> If you wish, I can send you coverage log for simple code.
> BTW, what is your testing environment, platform, interpreter, etc.?
> My code works on Windows XP/Vista/7 and Ubuntu 11.04.
> Remember that, (from docstring) "The changes may therefore not be in
> the record itself, but in a dependent child record."
> It looks like you need method to check if only current biz context
> in chain is changed, however I can't see application for it.
> And this is the point, how isAnyCHanged() is suitable for,
> return true if*any*  row is changed, so if current one is, we don't
> need to check others.

I found it by running the test in dabo/biz/test/test_dBizobj.py

mac:~ pmcnett$ cd dabo
mac:dabo pmcnett$ svn up -r 6936
U    dabo/biz/dBizobj.py
Updated to revision 6936.
mac:dabo pmcnett$ python dabo/biz/test/test_dBizobj.py

[snip]
======================================================================
FAIL: testChildren (__main__.Test_dBizobj)
----------------------------------------------------------------------
Traceback (most recent call last):
   File "dabo/biz/test/test_dBizobj.py", line 415, in testChildren
     self.assertEqual(bizChild.isAnyChanged(), False)
AssertionError: None != False

[snip]

This error is simply caused by returning the result of self.scan() instead of 
returning the value of exitScan. Patching this with:

Index: dabo/biz/dBizobj.py
===================================================================
--- dabo/biz/dBizobj.py (revision 6936)
+++ dabo/biz/dBizobj.py (working copy)
@@ -1522,10 +1522,10 @@
                def _isThisChanged():
                        self.exitScan = self._isChanged(True, 
includeNewUnchanged, withChildren)
                        return self.exitScan
+               self.scan(_isThisChanged, scanRequeryChildren=False)
+               return self.exitScan

-               return self.scan(_isThisChanged, scanRequeryChildren=False)

-
        def isChanged(self, includeNewUnchanged=None, withChildren=True):
                """
                Return True if data has changed in this bizobj and any children.


results in progress, but exposes a different problem:
======================================================================
FAIL: After the dabo web server stuff and the @remote calls got added, only
----------------------------------------------------------------------
Traceback (most recent call last):
   File "dabo/biz/test/test_dBizobj.py", line 671, in 
testChangesToTwoChildRecords
     self.assertEqual(bizMain.getChangedRows(), [0])
AssertionError: [0, 1, 2] != [0]

======================================================================
FAIL: Do the same test as for save, but with cancelAll().
----------------------------------------------------------------------
Traceback (most recent call last):
   File "dabo/biz/test/test_dBizobj.py", line 684, in 
testChangesToTwoChildRecords_cancel
     self.testChangesToTwoChildRecords("cancel")
   File "dabo/biz/test/test_dBizobj.py", line 671, in 
testChangesToTwoChildRecords
     self.assertEqual(bizMain.getChangedRows(), [0])
AssertionError: [0, 1, 2] != [0]

The problem is that exitScan isn't being reset to False, so when 
getChangedRows() 
scans the records, it finds changes in Row0, so exitScan is True. Then the 
scanfunc 
in getChangedRows() stops scanning because of the exitScan value, resulting in 
the 
non-changed records being reported as changed. We have a scan within a scan, 
and 
exitScan is only reset at the beginning of the outer scan.

Changing the patch to:
Index: dabo/biz/dBizobj.py
===================================================================
--- dabo/biz/dBizobj.py (revision 6936)
+++ dabo/biz/dBizobj.py (working copy)
@@ -1521,11 +1521,12 @@
                """
                def _isThisChanged():
                        self.exitScan = self._isChanged(True, 
includeNewUnchanged, withChildren)
-                       return self.exitScan
+               self.scan(_isThisChanged, scanRequeryChildren=False)
+               ret = self.exitScan
+               self.exitScan = False
+               return ret

-               return self.scan(_isThisChanged, scanRequeryChildren=False)

-
        def isChanged(self, includeNewUnchanged=None, withChildren=True):
                """
                Return True if data has changed in this bizobj and any children.

Results in only the encoding error failing the test.


Paul

_______________________________________________
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