def make_app(set_path=False, db_setup=True, testing=False): # If you are reading this code and wonder how to access the app: # >>> from flask import current_app as app # This only works while inside an application context but you really shouldn't have any # reason to access it outside this method without being inside an application context. # When set_path is enabled, SERVER_NAME and APPLICATION_ROOT are set according to BaseURL # so URLs can be generated without an app context, e.g. in the indico shell if _app_ctx_stack.top: Logger.get('flask').warn('make_app({}) called within app context, using existing app:\n{}'.format( set_path, '\n'.join(traceback.format_stack()))) return _app_ctx_stack.top.app app = IndicoFlask('indico', static_folder=None, template_folder='web/templates') app.config['TESTING'] = testing fix_root_path(app) configure_app(app, set_path) setup_jinja(app) with app.app_context(): setup_assets() if db_setup: configure_db(app) extend_url_map(app) add_handlers(app) add_blueprints(app) if app.config['INDICO_COMPAT_ROUTES']: add_compat_blueprints(app) if not app.config['TESTING']: add_plugin_blueprints(app) Logger.init_app(app) return app
def make_app(set_path=False, testing=False): # If you are reading this code and wonder how to access the app: # >>> from flask import current_app as app # This only works while inside an application context but you really shouldn't have any # reason to access it outside this method without being inside an application context. # When set_path is enabled, SERVER_NAME and APPLICATION_ROOT are set according to BaseURL # so URLs can be generated without an app context, e.g. in the indico shell if _app_ctx_stack.top: Logger.get('flask').warn( 'make_app({}) called within app context, using existing app:\n{}'. format(set_path, '\n'.join(traceback.format_stack()))) return _app_ctx_stack.top.app app = IndicoFlask('indico', static_folder=None, template_folder='web/templates') app.config['TESTING'] = testing fix_root_path(app) configure_app(app, set_path) celery.init_app(app) babel.init_app(app) multipass.init_app(app) oauth.init_app(app) setup_jinja(app) with app.app_context(): setup_assets() configure_db(app) mm.init_app(app) extend_url_map(app) add_handlers(app) setup_request_stats(app) add_blueprints(app) Logger.init_app(app) plugin_engine.init_app(app, Logger.get('plugins')) if not plugin_engine.load_plugins(app): raise Exception('Could not load some plugins: {}'.format(', '.join( plugin_engine.get_failed_plugins(app)))) # Below this points plugins are available, i.e. sending signals makes sense add_plugin_blueprints(app) # themes can be provided by plugins with app.app_context(): register_theme_sass() signals.app_created.send(app) return app
def make_app(set_path=False, db_setup=True, testing=False): # If you are reading this code and wonder how to access the app: # >>> from flask import current_app as app # This only works while inside an application context but you really shouldn't have any # reason to access it outside this method without being inside an application context. # When set_path is enabled, SERVER_NAME and APPLICATION_ROOT are set according to BaseURL # so URLs can be generated without an app context, e.g. in the indico shell if _app_ctx_stack.top: Logger.get("flask").warn( "make_app({}) called within app context, using existing app:\n{}".format( set_path, "\n".join(traceback.format_stack()) ) ) return _app_ctx_stack.top.app app = IndicoFlask("indico", static_folder=None, template_folder="web/templates") app.config["TESTING"] = testing fix_root_path(app) configure_app(app, set_path) celery.init_app(app) babel.init_app(app) multipass.init_app(app) oauth.init_app(app) setup_jinja(app) with app.app_context(): setup_assets() if db_setup: configure_db(app) extend_url_map(app) add_handlers(app) add_blueprints(app) Logger.init_app(app) plugin_engine.init_app(app, Logger.get("plugins")) if not plugin_engine.load_plugins(app): raise Exception("Could not load some plugins: {}".format(", ".join(plugin_engine.get_failed_plugins(app)))) # Below this points plugins are available, i.e. sending signals makes sense add_plugin_blueprints(app) signals.app_created.send(app) return app
def make_app(set_path=False, db_setup=True, testing=False): # If you are reading this code and wonder how to access the app: # >>> from flask import current_app as app # This only works while inside an application context but you really shouldn't have any # reason to access it outside this method without being inside an application context. # When set_path is enabled, SERVER_NAME and APPLICATION_ROOT are set according to BaseURL # so URLs can be generated without an app context, e.g. in the indico shell if _app_ctx_stack.top: Logger.get('flask').warn( 'make_app({}) called within app context, using existing app:\n{}'. format(set_path, '\n'.join(traceback.format_stack()))) return _app_ctx_stack.top.app app = IndicoFlask('indico', static_folder=None, template_folder='web/templates') app.config['TESTING'] = testing fix_root_path(app) configure_app(app, set_path) setup_jinja(app) with app.app_context(): setup_assets() if db_setup: configure_db(app) extend_url_map(app) add_handlers(app) add_blueprints(app) if app.config['INDICO_COMPAT_ROUTES']: add_compat_blueprints(app) if not app.config['TESTING']: add_plugin_blueprints(app) Logger.init_app(app) return app