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

b/snf-common/synnefo/settings/setup/services.py
57 57

  
58 58

  
59 59
def setup_base_urls(settings):
60
    import os
60 61
    for component_name in settings.SYNNEFO_COMPONENTS.keys():
61 62
        name_upper = component_name.upper()
62 63
        base_url_name = name_upper + '_BASE_URL'
......
64 65
        base_path_name = name_upper + '_BASE_PATH'
65 66
        base_url = getattr(settings, base_url_name, None)
66 67
        if base_url is None:
67
            m = ("No '{setting_name}' setting found even though "
68
                 "component '{component_name}' is installed!\n")
69
            m = m.format(setting_name=base_url_name,
70
                         component_name=component_name)
71
            raise AssertionError(m)
68
            # try environment variable
69
            base_url = os.environ.get(base_url_name)
70
            if base_url is None:
71
                # give up
72
                m = ("No '{setting_name}' setting found even though "
73
                     "component '{component_name}' is installed!\n")
74
                m = m.format(setting_name=base_url_name,
75
                             component_name=component_name)
76
                raise AssertionError(m)
77
            else:
78
                setattr(settings, base_url_name, base_url)
72 79

  
73 80
        base_host, base_path = parse_base_url(base_url)
74 81
        setattr(settings, base_host_name, base_host)

Also available in: Unified diff