Exemplo n.º 1
0
    def determine_selected_profile(self):
        # if we find the value in the environment, use it
        profile = app_environ_get(self.app_import_name, 'CONFIG_PROFILE')
        if profile is not None:
            return profile

        use_test_profile = app_environ_get(self.app_import_name,
                                           'USE_TEST_PROFILE', '')
        if use_test_profile.strip() or self.use_test_profile:
            return 'TestProfile'

        # look for it in the app's main config file (e.g. myapp.config)
        app_config = import_string('{}.config'.format(self.app_import_name),
                                   silent=True)
        if app_config and hasattr(app_config, 'DEFAULT_PROFILE'):
            profile = app_config.DEFAULT_PROFILE

        # Look for it in all the config files found.  This loops from lowest-priority config file
        # to highest priority, so the last file found with a value is kept.  Accordingly, any app
        # specific file has priority over the app's main config file, which could be set just above.
        for fpath, objects in self.config_file_objs:
            if 'DEFAULT_PROFILE' in objects:
                profile = objects['DEFAULT_PROFILE']

        return profile
Exemplo n.º 2
0
    def determine_selected_profile(self):
        # if we find the value in the environment, use it
        profile = app_environ_get(self.app_import_name, 'CONFIG_PROFILE')
        if profile is not None:
            return profile

        # look for it in all the config files found
        for fpath, objects in self.config_file_objs:
            if 'DEFAULT_PROFILE' in objects:
                profile = objects['DEFAULT_PROFILE']

        return profile
Exemplo n.º 3
0
def _config_profile(appcls):
    config_profile = 'TestProfile'
    if appcls.import_name is not None:
        config_profile = app_environ_get(appcls.import_name, 'CONFIG_PROFILE',
                                         config_profile)
    return config_profile