On 10/27/11 6:37 AM, Jacek Kałucki wrote:
> But problem still exist, I mean that isAnyChanged() method doesn't detect all 
> changes
> anymore, because it checks only current context.
> It seems we can't have our cake and eat it too.

You are right, I didn't think these changes completely through. I think some of 
my 
refactoring was good, but the problem comes down to preciseness versus 
performance. I 
know you already understand the issues, but here's my outline to help me and 
maybe 
others understand the problem:

+ Most precise answer to isAnyChanged():
   + scan the rows in the bizobj and all children down the hierarchy
     + slow, because:
       + expensive to scan a bizobj
     + won't result in false positives, because:
       + only cursors in context[1] are checked
     + won't result in false negatives, either

+ Quickest answer to isAnyChanged():
   + ask all cursors in the bizobj and all children down the hierarchy
     + fast, because:
      + each cursor just needs to check its _mementos and _newRecords
      + no scanning of bizobjs
     + won't result in false negatives, since all cursors are ultimately checked
     + can result in false positives, since cursors out of context are also 
checked

[1] When a parent bizobj changes RowNumber from 0 to 1, the children are 
requeried 
but the older child cursors (associated with Row 0 in the parent) are kept 
around. If 
a field was changed in a child of Row 0, but we are now on Parent Row 1, asking 
parent.isAnyChanged() should return True, but asking child.isAnyChanged() 
should 
return False since those cursors associated with parent Row 0 are "out of 
context".

-------------

I want to get to the point where we can somehow use the quickest answer above 
(no 
scanning), yet still be as precise. I was going to suggest doing it by burning 
some 
(fast) cycles using a flag in each cursor indicating whether it is currently in 
context or not (concept of context doesn't exist at the cursor level though, so 
it 
would be the bizobj that would decorate the cursor objects). When the parent 
row 
number changes, there's a cycle of setting the current parent in the children 
and 
requerying. At that point we would do:

# before the current parent is changed:
self._CurrentCursor._inContext = False
# after the current parent is changed:
self._CurrentCursor._inContext = True

But there's where it breaks down: the context is dependent on the parent biz 
row 
number so we need to check all contexts that are going to match any row in the 
parent, so at a given point in time we wouldn't have all the cursors we want to 
check 
in context.

So, to answer isAnyChanged(), I accept that we must scan the child bizobjs, one 
by 
one. Hopefully typing up this message keeps it fresh in my mind.

You had a couple bugs in your changes though, and I'll commit the fixes right 
now.

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