dabo Commit Revision 5965 Date: 2010-08-31 06:01:52 -0700 (Tue, 31 Aug 2010) Author: Ed Trac: http://trac.dabodev.com/changeset/5965
Changed: U trunk/dabo/ui/uiwx/dForm.py U trunk/dabo/ui/uiwx/dPemMixin.py Log: Added some logic to prevent infinite loops when using field-level validation. Diff: Modified: trunk/dabo/ui/uiwx/dForm.py =================================================================== --- trunk/dabo/ui/uiwx/dForm.py 2010-08-27 18:21:09 UTC (rev 5964) +++ trunk/dabo/ui/uiwx/dForm.py 2010-08-31 13:01:52 UTC (rev 5965) @@ -55,6 +55,8 @@ self._holdStatusText = "" # Holds the dataSource passed to the method self.dataSourceParameter = None + # Flag to prevent infinite loops when doing field-level validation + self._fieldValidationControl = None def _beforeSetProperties(self, props): @@ -774,6 +776,9 @@ BusinessRuleViolation exception will be raised, and the form can then respond to this. """ + if self._fieldValidationControl: + # Prevent infinite loops + return ds = ctrl.DataSource df = ctrl.DataField val = ctrl.Value @@ -809,6 +814,13 @@ """ self.StatusText = _(u"Validation failed for %(df)s: %(err)s") % locals() dabo.ui.callAfter(ctrl.setFocus) + self._fieldValidationControl = ctrl + + + def _controlGotFocus(self, ctrl): + if self._fieldValidationControl is ctrl: + # Clear it + self._fieldValidationControl = None def onFieldValidationPassed(self, ctrl, ds, df, val): Modified: trunk/dabo/ui/uiwx/dPemMixin.py =================================================================== --- trunk/dabo/ui/uiwx/dPemMixin.py 2010-08-27 18:21:09 UTC (rev 5964) +++ trunk/dabo/ui/uiwx/dPemMixin.py 2010-08-31 13:01:52 UTC (rev 5965) @@ -554,6 +554,7 @@ def __onWxGotFocus(self, evt): + self.Form._controlGotFocus(self) self._pushStatusText() if isinstance(self, dabo.ui.dGrid): ## Continuation of ugly workaround for grid focus event. Only raise the _______________________________________________ Post Messages to: Dabo-dev@leafe.com 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/20100831130152.de4ec318...@mail.paulmcnett.com