dabo Commit
Revision 6846
Date: 2011-09-19 10:08:19 -0700 (Mon, 19 Sep 2011)
Author: Jacekk
Trac: http://trac.dabodev.com/changeset/6846

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

Log:
Some code consolidation in isChanged() method inspired by Paul's suggestion.

Diff:
Modified: trunk/dabo/biz/dBizobj.py
===================================================================
--- trunk/dabo/biz/dBizobj.py   2011-09-19 14:47:02 UTC (rev 6845)
+++ trunk/dabo/biz/dBizobj.py   2011-09-19 17:08:19 UTC (rev 6846)
@@ -1493,25 +1493,8 @@
                return False
 
 
-       def isRowChanged(self, includeNewUnchanged=None):
+       def isChanged(self, includeNewUnchanged=None, withChildren=True):
                """
-               Return True if data has changed in the current and only current 
row
-               of this bizobj, without any children.
-               """
-               if not self.RowCount:
-                       # If there are no records, there can be no changes
-                       return False
-               cc = self._CurrentCursor
-               if cc is None:
-                       # No cursor, no changes.
-                       return False
-               if includeNewUnchanged is None:
-                       includeNewUnchanged = self.SaveNewUnchanged
-               return cc.isChanged(allRows=False, 
includeNewUnchanged=includeNewUnchanged)
-
-
-       def isChanged(self, includeNewUnchanged=None):
-               """
                Return True if data has changed in this bizobj and any children.
 
                By default, only the current record is checked. Call 
isAnyChanged() to
@@ -1520,10 +1503,17 @@
                if not self.RowCount:
                        # If there are no records, there can be no changes.
                        return False
+               cursor = self._CurrentCursor
+               if cursor is None:
+                       # No cursor, no changes.
+                       return False
+               if includeNewUnchanged is None:
+                       includeNewUnchanged = self.SaveNewUnchanged
 
-               self.__areThereAnyChanges = ret = 
self.isRowChanged(includeNewUnchanged=includeNewUnchanged)
+               self.__areThereAnyChanges = ret = 
cursor.isRowChanged(allRows=False,
+                               includeNewUnchanged=includeNewUnchanged)
 
-               if not ret:
+               if not ret and withChildren:
                        for child in self.getChildren():
                                ret = 
child.isAnyChanged(includeNewUnchanged=includeNewUnchanged)
                                if ret:
@@ -1531,6 +1521,15 @@
                return ret
 
 
+       def isRowChanged(self, includeNewUnchanged=None):
+               """
+               Return True if data has changed in the current and only current 
row
+               of this bizobj, without any children.
+               """
+               return self.isChanged(includeNewUnchanged=includeNewUnchanged,
+                               withChildren=False)
+
+
        def onDeleteLastRecord(self):
                """Hook called when the last record has been deleted from the 
data set."""
                pass



_______________________________________________
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