dabo Commit
Revision 5602
Date: 2010-01-26 13:50:25 -0800 (Tue, 26 Jan 2010)
Author: Paul
Trac: http://trac.dabodev.com/changeset/5602
Changed:
U trunk/dabo/biz/dBizobj.py
U trunk/dabo/db/dCursorMixin.py
Log:
Fixed the problem described by Jacek in dabo-users today where the cursor won't
save a new unchanged record even if the bizobj is set to SaveNewUnchanged. Did
this by refactoring the code to call the common isChanged() function instead
of checking _newRecords and _mementos directly.
Diff:
Modified: trunk/dabo/biz/dBizobj.py
===================================================================
--- trunk/dabo/biz/dBizobj.py 2010-01-22 15:25:06 UTC (rev 5601)
+++ trunk/dabo/biz/dBizobj.py 2010-01-26 21:50:25 UTC (rev 5602)
@@ -433,7 +433,7 @@
# will reset it to False:
isAdding = self.IsAdding
try:
- cursor.save()
+ cursor.save(includeNewUnchanged=self.SaveNewUnchanged)
if isAdding:
# Call the hook method for saving new records.
self._onSaveNew()
Modified: trunk/dabo/db/dCursorMixin.py
===================================================================
--- trunk/dabo/db/dCursorMixin.py 2010-01-22 15:25:06 UTC (rev 5601)
+++ trunk/dabo/db/dCursorMixin.py 2010-01-26 21:50:25 UTC (rev 5602)
@@ -1271,8 +1271,8 @@
raise dException.NoRecordsException(_("No records in
data set"))
- def save(self, allRows=False):
- """ Save any changes to the data back to the data store."""
+ def save(self, allRows=False, includeNewUnchanged=False):
+ """ Save any changes to the current record back to the data
store."""
# Make sure that there is data to save
if self.RowCount <= 0:
raise dException.NoRecordsException(_("No data to
save"))
@@ -1305,16 +1305,19 @@
self._syncAuxProperties()
- # Faster to deal with 2 specific cases: all rows or just
current row
if allRows:
- pks_to_save = self._mementos.keys()
- for pk_id in pks_to_save:
- row, rec = self._getRecordByPk(pk_id)
- saverow(row)
+ # This branch doesn't happen when called from dBizobj
(not sure if
+ # we really need the allRows arg at all).
+ rows =
self.getChangedRows(includeNewUnchanged=includeNewUnchanged)
else:
- pk = self.pkExpression()
- if pk in self._mementos.keys():
- saverow(self.RowNumber)
+ # This branch results in redundant isChanged() call
when called from
+ # dBizobj.saveAll(), but it needs to be here because
dBizobj.save()
+ # doesn't check it.
+ rows = []
+ if self.isChanged(allRows=False,
includeNewUnchanged=includeNewUnchanged):
+ rows = [self.RowNumber]
+ for row in rows:
+ saverow(row)
def __saverow(self, row):
_______________________________________________
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]