From ae4b505ef7e31ede3aab3c2b3ea9a0ed4d5f7cb1 Mon Sep 17 00:00:00 2001 From: Howard Johnson Date: May 28 2016 11:18:45 +0000 Subject: Convert stored Condition config options back to booleans All options types are stored as strings in the backend database. The Condition config option type is a subclass of the Pick option that has only the Python True and False values as valid values. When a specific value for the option is stored into the database, this is rendered into the text strings 'True' or 'False'. When the option is loaded back from the database, it remains a string. This causes the issue that any "it option" style checks will always evaluate to true. This manifests in the plugin configuration pages, where the checkboxes for Condition options are always checked, even if the value is set to false in the database. This patch adds code to the Condition import_value function to coerce the strings into Python bools. The authfas plugin has a Condition option that it tries to use the value of as a string, so convert that to a boolean operation. Signed-off-by: Howard Johnson --- diff --git a/ipsilon/login/authfas.py b/ipsilon/login/authfas.py index d0b834a..eee0438 100644 --- a/ipsilon/login/authfas.py +++ b/ipsilon/login/authfas.py @@ -169,7 +169,7 @@ Form based login Manager that uses the Fedora Authentication Server def get_tree(self, site): self.fpc = FasProxyClient(base_url=self.fas_url, useragent=self.user_agent, - insecure=(self.insecure == 'YES')) + insecure=self.insecure) self.page = FAS(site, self, 'login/fas') return self.page diff --git a/ipsilon/util/config.py b/ipsilon/util/config.py index 07c76c0..3607e79 100644 --- a/ipsilon/util/config.py +++ b/ipsilon/util/config.py @@ -431,8 +431,8 @@ class Condition(Pick): def __init__(self, name, description, default_value=False, readonly=False): - # The db stores 1/0. Convert the passed-in value if - # necessary + # We're not too picky about what data we get, but we make sure it's a + # boolean by the time we're done with it if default_value in [u'1', 'True', True]: default_value = True else: @@ -442,7 +442,11 @@ class Condition(Pick): readonly=readonly) def import_value(self, value): - self._assigned_value = value + # Convert the text string stored in the database back to a boolean + if value == 'True': + self._assigned_value = True + elif value == 'False': + self._assigned_value = False class ConfigHelper(Log):