Revision 7877e6d3 snf-common/synnefo/settings/setup/__init__.py

b/snf-common/synnefo/settings/setup/__init__.py
52 52
    def __init__(self, default_value, example=None, description=None):
53 53
        self.default_value = default_value
54 54
        if example is None:
55
            example_value = default_value
55
            example = default_value
56 56
        self.example_value = example
57 57
        self.description = description
58 58

  
......
100 100
    configured = {}
101 101
    defaults = settings._DEFAULTS
102 102
    failed = []
103
    import os
104
    relax_mandatory = bool(os.environ.get('SYNNEFO_RELAX_MANDATORY_SETTINGS'))
103 105

  
104 106
    for name, value in get_all_settings(settings):
105 107
        if isinstance(value, Example):
106
            m = ("Setting '{name}' is mandatory. "
107
                 "Please provide a real value. "
108
                 "Example value: '{example}'")
109
            m = m.format(name=name, example=value.example_value)
110
            failed.append(m)
108
            if relax_mandatory:
109
                setattr(settings, name, value.example_value)
110
            else:
111
                m = ("Setting '{name}' is mandatory. "
112
                     "Please provide a real value. "
113
                     "Example value: '{example}'")
114
                m = m.format(name=name, example=value.example_value)
115
                failed.append(m)
111 116
        elif isinstance(value, Default):
112 117
            m = "unprocessed default setting in post processing"
113 118
            raise AssertionError(m)

Also available in: Unified diff