Użytkownik Ed Leafe napisał:
>
>       Actually, isAnyChanged() should return False: new, unchanged records  
> can be safely ignored when determining if the buffer is dirty.
>
>       Where does isAnyChanged() come into play?
>
>   

I'm so sorry, you are absolutely right.
But your code still doesn't work.
This is why (excerpt from dCursorMixin.cancel method):
{{{
            if self._newRecords:
                recs = list(recs)
                delrecs_ids = self._newRecords.keys()
                delrecs_idx = []
                for rec_id in delrecs_ids:
                    # Remove any memento associated with the canceled 
new record, and
                    # append to the list of indexes to delete.
                    row, rec = self._getRecordByPk(rec_id)
                    self._clearMemento(row)
                    delrecs_idx.append(self._records._index(rec))
                delrecs_idx.sort(reverse=True)
                for idx in delrecs_idx:
                    del recs[idx]
                self._newRecords = {}
                recs = dDataSet(recs)
                if self.RowNumber >= self.RowCount:
                    self.RowNumber = self.RowCount - 1

            for rec_pk, mem in self._mementos.items():
                row, rec = self._getRecordByPk(rec_pk)
                for fld, val in mem.items():
                    self._records[row][fld] = val
            self._mementos = {}

        else:
            row = self.RowNumber
            rec = self._records[row]
            recKey = self.pkExpression(rec)
            if recKey in self._newRecords:
                # We simply need to remove the row, and clear the 
memento and newrec flag.
                self._clearMemento(row)
                self._clearNewRecord(row)
                recs = list(self._records)
                del recs[recs.index(rec)]
                self._records = dDataSet(recs)
                if self.RowNumber >= self.RowCount:
                    self.RowNumber = self.RowCount - 1
                return
}}}

When Paul's code is invoked, self._newRecords is empty list, so code 
after "else" is executed.
Within your code, self._newRecords is filled, so condition is true, but 
in this section,
content of "recs" dictionary is not propagated to self._records, like in 
code below,
that is why dataset, de facto remains unchanged.

-- 
Regards
Jacek Kałucki



_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/[email protected]

Reply via email to