# this module will usually be called up via the django # reloader, which is (in turn) called up by rapidsms's # server.py, which adds RAPIDSMS_INI to the environment. # just in case, though, check that it's defined rather # than repeating the filename selection logic here if not "RAPIDSMS_INI" in os.environ: raise( EnvironmentError, "The RAPIDSMS_INI environment variable is not " +\ "defined. Without it, settings.py doesn't know " +\ "which ini file to load settings from") # load the rapidsms configuration from rapidsms import Config RAPIDSMS_CONF = Config(os.environ["RAPIDSMS_INI"]) # since iterating and reading the config of apps is # common, build a handy dict of apps and their configs RAPIDSMS_APPS = dict([(app["type"], app) for app in RAPIDSMS_CONF["rapidsms"]["apps"]]) # this code bootstraps the i18n logic configuration, if # it is in the settings def _i18n_to_django_setting(language_settings): languages = [] for language in language_settings: if len(language) >= 2: languages.append((language[0], language[1]))
def setUp(self): fd, path = tempfile.mkstemp() ini = os.fdopen(fd, 'w') ini.write(TEST_INI) ini.close() self.config = Config(path)