[PATCH 2/2] Don't reset input check status when disabling a check (#1062273)

David Shea dshea at redhat.com
Wed Feb 12 20:05:13 UTC 2014


This changes the behavior of the InputCheck.enabled property so that
setting it to False does not clear the status of the InputCheck.
Disabled checks are removed from the failed_checks generator based on
the value of enabled instead of only the value of the check_status.
This allows a check to be temporaliy disabled and re-enabled without
changing its status, such as in the user spoke where the password match
checks on the password and confirm inputs call one another and use the
enabled property to avoid a loop.

Leaving enabled as a property even though it doesn't really need to be
one so that it can have a docstring explaining the situation.
---
 pyanaconda/ui/helpers.py | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/pyanaconda/ui/helpers.py b/pyanaconda/ui/helpers.py
index d09655c..898a0c5 100644
--- a/pyanaconda/ui/helpers.py
+++ b/pyanaconda/ui/helpers.py
@@ -252,16 +252,19 @@ class InputCheck(object):
 
     @property
     def enabled(self):
+        """Whether the check is enabled or not.
+
+           Disabling a check indicates that the status will not change if
+           the input changes. The value of check_status will be the result of
+           the last time the InputCheck was run when enabled. Disabled checks
+           will not be included in InputCheckHandler.failed_checks.
+        """
         return self._enabled
 
     @enabled.setter
     def enabled(self, value):
         self._enabled = value
 
-        # If disabling the check, clear the status
-        if not value:
-            self._check_status = None
-
 class InputCheckHandler(object):
     """Provide a framework for adding input validation checks to a screen.
 
@@ -349,7 +352,8 @@ class InputCheckHandler(object):
     @property
     def failed_checks(self):
         """A generator of all failed input checks"""
-        return (c for c in self._check_list if c.check_status != InputCheck.CHECK_OK)
+        return (c for c in self._check_list \
+                if c.enabled and c.check_status != InputCheck.CHECK_OK)
 
     @property
     def checks(self):
-- 
1.8.5.3



More information about the anaconda-patches mailing list