Changeset 3038
- Timestamp:
- 04/06/07 09:21:50 (2 years ago)
- Files:
-
- trunk/dabo/biz/dBizobj.py (modified) (2 diffs)
- trunk/dabo/db/dCursorMixin.py (modified) (2 diffs)
- trunk/dabo/ui/uiwx/dForm.py (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/dabo/biz/dBizobj.py
r3029 r3038 367 367 368 368 369 def cancelAll(self ):369 def cancelAll(self, ignoreNoRecords=None): 370 370 """Cancel all changes made to the current dataset, including all children.""" 371 self.scanChangedRows(self.cancel, allCursors=False )372 373 374 def cancel(self ):371 self.scanChangedRows(self.cancel, allCursors=False, ignoreNoRecords=ignoreNoRecords) 372 373 374 def cancel(self, ignoreNoRecords=None): 375 375 """Cancel all changes to the current record and all children. 376 376 … … 382 382 if errMsg: 383 383 raise dException.BusinessRuleViolation, errMsg 384 if ignoreNoRecords is None: 385 # Canceling changes when there are no records should 386 # normally not be a problem. 387 ignoreNoRecords = True 384 388 385 389 # Tell the cursor and all children to cancel themselves: 386 self._CurrentCursor.cancel( )390 self._CurrentCursor.cancel(ignoreNoRecords=ignoreNoRecords) 387 391 for child in self.__children: 388 child.cancelAll( )392 child.cancelAll(ignoreNoRecords=ignoreNoRecords) 389 393 390 394 self.afterCancel() trunk/dabo/db/dCursorMixin.py
r3025 r3038 630 630 #new_rec = self._newRecords.has_key(recKey) 631 631 #return not (memento is None and not new_rec) 632 return not (notmemento)632 return bool(memento) 633 633 634 634 … … 1201 1201 1202 1202 1203 def cancel(self, allRows=False ):1203 def cancel(self, allRows=False, ignoreNoRecords=None): 1204 1204 """ Revert any changes to the data set back to the original values.""" 1205 if not self.RowCount > 0: 1206 raise dException.NoRecordsException, _("No data to cancel.") 1207 1205 if ignoreNoRecords is None: 1206 ignoreNoRecords = True 1207 if self.RowCount == 0: 1208 if ignoreNoRecords: 1209 # Nothing to do! 1210 return 1211 else: 1212 raise dException.NoRecordsException, _("No data to cancel.") 1213 1208 1214 # Faster to deal with 2 specific cases: all rows or just current row 1209 1215 if allRows: trunk/dabo/ui/uiwx/dForm.py
r3033 r3038 96 96 97 97 98 def confirmChanges(self): 98 def refresh(self): 99 """For performance reasons, cache repeated calls.""" 100 dabo.ui.callAfterInterval(100, self.__refresh) 101 def __refresh(self): 102 super(BaseForm, self).refresh() 103 104 105 def update(self): 106 """For performance reasons, cache repeated calls.""" 107 dabo.ui.callAfterInterval(100, self.__update) 108 def __update(self): 109 super(BaseForm, self).update() 110 111 112 def confirmChanges(self, bizobjs=None): 99 113 """Ask the user if they want to save changes, discard changes, or cancel. 100 114 101 115 The user will be queried if the form's CheckForChanges property is True, and 102 if there are any pending changes on the form's bizobjs as specified in the 103 return value of getBizobjsToCheck(). 116 if there are any pending changes on the form's bizobjs as specified in either 117 the 'bizobjs' parameter, or, if no parameter is sent, the return value of 118 getBizobjsToCheck(). 104 119 105 120 If all the above are True, the dialog will be presented. "Yes" will cause … … 114 129 # Don't bother checking 115 130 return True 116 bizList = self.getBizobjsToCheck() 131 if bizobjs is None: 132 bizobjs = self.getBizobjsToCheck() 133 if not isinstance(bizobjs, (list, tuple)): 134 bizList = (bizobjs, ) 135 else: 136 bizList = bizobjs 117 137 changedBizList = [] 118 138 … … 124 144 queryMessage = self.getConfirmChangesQueryMessage(changedBizList) 125 145 response = dabo.ui.areYouSure(queryMessage, parent=self) 146 147 print "RESP", response 126 148 if response == None: ## cancel 127 149 # Don't let the form close, or requery happen … … 132 154 elif response == False: ## no 133 155 for biz in changedBizList: 134 self.cancel(dataSource=biz.DataSource) 156 if biz.RowCount: 157 self.cancel(dataSource=biz.DataSource) 135 158 return True 136 159 … … 155 178 required bizobjs. 156 179 """ 157 return [self.PrimaryBizobj]180 return (self.PrimaryBizobj, ) 158 181 159 182 … … 215 238 self.update() 216 239 self.afterPointerMove() 240 self.refresh() 217 241 return True 218 242 … … 315 339 316 340 self.afterSave() 341 self.refresh() 317 342 return True 318 343 319 344 320 def cancel(self, dataSource=None ):345 def cancel(self, dataSource=None, ignoreNoRecords=None): 321 346 """ Ask the bizobj to cancel its changes. 322 347 … … 329 354 return 330 355 self.activeControlValid() 356 if ignoreNoRecords is None: 357 ignoreNoRecords = True 331 358 332 359 err = self.beforeCancel() … … 336 363 try: 337 364 if self.SaveAllRows: 338 bizobj.cancelAll( )365 bizobj.cancelAll(ignoreNoRecords=ignoreNoRecords) 339 366 else: 340 bizobj.cancel( )367 bizobj.cancel(ignoreNoRecords=ignoreNoRecords) 341 368 self.setStatusText(_("Changes to %s canceled.") % ( 342 369 self.SaveAllRows and "all records" or "current record",)) 343 370 self.update() 371 except dException.NoRecordsException, e: 372 dabo.errorLog.write(_("Cancel failed; no records to cancel.")) 344 373 except dException.dException, e: 345 374 dabo.errorLog.write(_("Cancel failed with response: %s") % str(e)) 346 375 self.notifyUser(str(e), title=_("Cancel Not Allowed") ) 347 376 self.afterCancel() 377 self.refresh() 348 378 349 379 … … 368 398 self.notifyUser(err) 369 399 return 370 371 if not self.confirmChanges(): 400 if not self.confirmChanges(bizobjs=bizobj): 372 401 # A False from confirmChanges means "don't proceed" 373 402 return 374 403 375 # self.setStatusText(_("Please wait... requerying dataset..."))376 377 404 try: 378 405 busy = dabo.ui.busyInfo(_("Please wait... requerying dataset...")) … … 388 415 # Notify listeners that the row number changed: 389 416 self.raiseEvent(dEvents.RowNumChanged) 390 391 417 # We made it through without errors 392 418 ret = True … … 420 446 421 447 self.afterRequery() 448 self.refresh() 422 449 return ret 423 450 … … 464 491 self.afterDelete() 465 492 self.update() 466 493 self.refresh() 494 467 495 468 496 def deleteAll(self, dataSource=None, message=None): … … 496 524 self.afterDeleteAll() 497 525 self.update() 526 self.refresh() 498 527 499 528 … … 525 554 self.afterNew() 526 555 self.update() 556 self.refresh() 527 557 528 558
