def __init__(self, root_url=None, template_folder=None): """ :param root_url: root url for Madame :param template_folder: sets a different template folder """ if template_folder is None: template_folder = os.path.join(get_main_path(), "templates") super(Madame, self).__init__(__package__, template_folder=template_folder) self.load_config() self.init_database() self.load_schemas() self.register(root_url)
def load_config(self): """Loads config from default_settings.py, then tries to load it from the file config.py and, if it fails, loads it from the envvar 'MADAME_SETTINGS' Defaults : DEBUG is set to TRUE """ self.config.from_object('madame.default_settings') try: file = os.path.join(get_main_path(), "config.py") self.config.from_pyfile(file, silent=False) except IOError: pass try: self.config.from_envvar('MADAME_SETTINGS', silent=False) except RuntimeError: pass