Changeset 3044
- Timestamp:
- 04/10/2007 09:17:53 AM (2 years ago)
- Files:
-
- trunk/dabo/biz/dBizobj.py (modified) (6 diffs)
- trunk/dabo/dConstants.py (modified) (1 diff)
- trunk/dabo/dException.py (modified) (1 diff)
- trunk/dabo/db/dCursorMixin.py (modified) (1 diff)
- trunk/dabo/ui/dDataControlMixinBase.py (modified) (3 diffs)
- trunk/dabo/ui/uiwx/dForm.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/dabo/biz/dBizobj.py
r3038 r3044 2 2 import re 3 3 import dabo 4 import dabo.dConstants as k 4 import dabo.dConstants as kons 5 5 from dabo.db.dCursorMixin import dCursorMixin 6 6 from dabo.dLocalize import _ … … 89 89 ### RESTRICT - don't allow action if there are child records 90 90 ### CASCADE - changes to the parent are cascaded to the children 91 self.deleteChildLogic = k .REFINTEG_CASCADE # child records will be deleted92 self.updateChildLogic = k .REFINTEG_IGNORE # parent keys can be changed w/o91 self.deleteChildLogic = kons.REFINTEG_CASCADE # child records will be deleted 92 self.updateChildLogic = kons.REFINTEG_IGNORE # parent keys can be changed w/o 93 93 # affecting children 94 self.insertChildLogic = k .REFINTEG_IGNORE # child records can be inserted94 self.insertChildLogic = kons.REFINTEG_IGNORE # child records can be inserted 95 95 # even if no parent record exists. 96 96 ########################################## … … 436 436 raise dException.dException, _("No key field defined for table: ") + self.DataSource 437 437 438 if self.deleteChildLogic == k .REFINTEG_RESTRICT:438 if self.deleteChildLogic == kons.REFINTEG_RESTRICT: 439 439 # See if there are any child records 440 440 for child in self.__children: … … 454 454 # populate them with data for the current record in this bizobj. 455 455 for child in self.__children: 456 if self.deleteChildLogic == k .REFINTEG_CASCADE:456 if self.deleteChildLogic == kons.REFINTEG_CASCADE: 457 457 child.deleteAll(startTransaction=False) 458 458 else: … … 852 852 errMsg = "" 853 853 message = self.validateField(fld, val) 854 if message == kons.BIZ_DEFAULT_FIELD_VALID: 855 # No validation was done 856 print "DEFAULT VALID" 857 return 854 858 if message: 855 859 errMsg += message 856 860 if errMsg: 857 861 raise dException.BusinessRuleViolation, errMsg 862 else: 863 print "BIZ RULE PASSED" 864 raise dException.BusinessRulePassed 858 865 859 866 … … 866 873 from being changed. 867 874 """ 868 pass875 return kons.BIZ_DEFAULT_FIELD_VALID 869 876 870 877 trunk/dabo/dConstants.py
r1591 r3044 28 28 DLG_OK = 0 29 29 DLG_CANCEL = -1 30 31 # Flag to indicate that field validation was skipped 32 BIZ_DEFAULT_FIELD_VALID = "Dabo default field validation".split(" ") trunk/dabo/dException.py
r2994 r3044 20 20 21 21 class BusinessRuleViolation(dException): 22 pass 23 24 class BusinessRulePassed(dException): 22 25 pass 23 26 trunk/dabo/db/dCursorMixin.py
r3042 r3044 628 628 recKey = self.pkExpression(rec) 629 629 memento = self._mementos.get(recKey, None) 630 631 630 return bool(memento) 632 631 trunk/dabo/ui/dDataControlMixinBase.py
r3021 r3044 55 55 if not self._inFldValid: 56 56 self._oldVal = self.Value 57 self._inFldValid = False58 57 try: 59 58 if self.SelectOnEntry: … … 66 65 def _lostFocus(self): 67 66 ok = True 68 if self._ oldVal != self.Value:67 if self._inFldValid or (self._oldVal != self.Value): 69 68 # Call the field-level validation if indicated. 70 69 if hasattr(self.Form, "validateField"): … … 78 77 # Everything's hunky dory; push the value to the DataSource. 79 78 self.flushValue() 79 self._inFldValid = False 80 80 try: 81 81 if self.SelectOnEntry: trunk/dabo/ui/uiwx/dForm.py
r3039 r3044 708 708 except dException.BusinessRuleViolation, e: 709 709 self.onFieldValidationFailed(ctrl, ds, df, val, e) 710 except dException.BusinessRulePassed: 711 self.onFieldValidationPassed(ctrl, ds, df, val) 712 ret = True 710 713 return ret 711 714 … … 716 719 appropriately for your application. 717 720 """ 718 self. setStatusText(_("Validation failed for %s: %s") % (df, err))721 self.StatusText = _("Validation failed for %s: %s") % (df, err) 719 722 dabo.ui.callAfter(ctrl.setFocus) 723 724 725 def onFieldValidationPassed(self, ctrl, ds, df, val): 726 """Basic handling when field-level validation succeeds. 727 You should override it with your own code to handle this event 728 appropriately for your application. 729 """ 730 self.StatusText = "" 720 731 721 732
