Issue #36 new

ConfigurationGroup.items method is broken

Rafał Stożek
created an issue

Because of some "funny" (not really) modifications in ConfigurationGroup.values() method items() is unable to return valid results (in my case some of the settings had values of other settings).

Comments (2)

  1. Hynek Cernoch

    Can it be reproduced with more information? Do you see old values or values of a different site or completely differently?.

    I am finishing a fix of all clear issues.

  2. Hynek Cernoch

    Yes, it was a strange bug related only to settings with a requires condition. I found it accidentally while reading the code before some edit. (The original description was vague for me.)

    How to reproduce it:

    livesettings/tests.py

    class ConfigTestRequires(TestCase):
        ....  # add this test method
        def test_conditional_items_regression(self):
            "issue #36: conditional vals in ConfigurationGroup.items()."
            c2 = config_get('req1', 'c2')
            c2.update(77)
            self.assertNotEqual(dict(self.g1.items())['c3'], 77)
            self.assertEqual(dict(self.g1.items())['c2'], 77)
    

    I think that it was not a good idea to redefine values so that
    len(group.keys() != len(group.values())

    The first minimalistic fix without backward incompatibilities is this:

    livesettings/values.py

    class ConfigurationGroup(SortedDotDict):
        ....  # add this test method
        def items(self):
            return [(v.key, v) for v in self.values()]
    
  3. Log in to comment