def load_paste_app(conf, app_name=None): """ Builds and returns a WSGI app from a paste config file. We assume the last config file specified in the supplied ConfigOpts object is the paste config file. :param conf: a cfg.ConfigOpts object :param app_name: name of the application to load :raises RuntimeError when config file cannot be located or application cannot be loaded from config file """ if app_name is None: app_name = conf.prog # append the deployment flavor to the application name, # in order to identify the appropriate paste pipeline app_name += _get_deployment_flavor(conf) conf_file = _get_deployment_config_file(conf) try: # Setup logging early setup_logging(conf) logger = logging.getLogger(app_name) logger.debug(_("Loading %(app_name)s from %(conf_file)s"), { 'conf_file': conf_file, 'app_name': app_name }) app = wsgi.paste_deploy_app(conf_file, app_name, conf) # Log the options used when starting if we're in debug mode... if conf.debug: conf.log_opt_values(logger, logging.DEBUG) return app except (LookupError, ImportError), e: raise RuntimeError("Unable to load %(app_name)s from " "configuration file %(conf_file)s." "\nGot: %(e)r" % locals())
def load_paste_app(conf, app_name=None): """ Builds and returns a WSGI app from a paste config file. We assume the last config file specified in the supplied ConfigOpts object is the paste config file. :param conf: a cfg.ConfigOpts object :param app_name: name of the application to load :raises RuntimeError when config file cannot be located or application cannot be loaded from config file """ if app_name is None: app_name = conf.prog # append the deployment flavor to the application name, # in order to identify the appropriate paste pipeline app_name += _get_deployment_flavor(conf) conf_file = _get_deployment_config_file(conf) try: # Setup logging early setup_logging(conf) logger = logging.getLogger(app_name) logger.debug(_("Loading %(app_name)s from %(conf_file)s"), {'conf_file': conf_file, 'app_name': app_name}) app = wsgi.paste_deploy_app(conf_file, app_name, conf) # Log the options used when starting if we're in debug mode... if conf.debug: conf.log_opt_values(logger, logging.DEBUG) return app except (LookupError, ImportError), e: raise RuntimeError("Unable to load %(app_name)s from " "configuration file %(conf_file)s." "\nGot: %(e)r" % locals())
def load_paste_app(conf, app_name=None): """ Builds and returns a WSGI app from a paste config file. We assume the last config file specified in the supplied ConfigOpts object is the paste config file. :param conf: a cfg.ConfigOpts object :param app_name: name of the application to load :raises RuntimeError when config file cannot be located or application cannot be loaded from config file """ if app_name is None: app_name = conf.prog # Assume paste config is in the last config file conf_file = os.path.abspath(conf.config_file[-1]) try: # Setup logging early setup_logging(conf) logger = logging.getLogger(app_name) app = wsgi.paste_deploy_app(conf_file, app_name, conf) # Log the options used when starting if we're in debug mode... if conf.debug: conf.log_opt_values(logging.getLogger(app_name), logging.DEBUG) return app except (LookupError, ImportError), e: raise RuntimeError("Unable to load %(app_name)s from " "configuration file %(conf_file)s." "\nGot: %(e)r" % locals())