def init(uwsgi=None, use_reloader=False): """Initialize globals and populate simulation dir""" from sirepo import uri_router app.sirepo_db_dir = cfg.db_dir simulation_db.init_by_server(app) uri_router.init(app, uwsgi) for err, file in simulation_db.SCHEMA_COMMON['customErrors'].items(): app.register_error_handler(int(err), _handle_error) runner.init(app, uwsgi, use_reloader) return app
def init(db_dir=None, uwsgi=None): """Initialize globals and populate simulation dir""" from sirepo import uri_router if db_dir: cfg.db_dir = py.path.local(db_dir) else: db_dir = cfg.db_dir uri_router.init(app, sys.modules[__name__], simulation_db) global _wsgi_app _wsgi_app = _WSGIApp(app, uwsgi) _BeakerSession().sirepo_init_app(app, db_dir) simulation_db.init_by_server(app, sys.modules[__name__]) for err, file in simulation_db.SCHEMA_COMMON['customErrors'].items(): app.register_error_handler(int(err), _handle_error) runner.init(app, uwsgi) return app
def init(uwsgi=None, use_reloader=False): """Initialize globals and populate simulation dir""" global _app if _app: return #: Flask app instance, must be bound globally _app = flask.Flask( __name__, static_folder=None, template_folder=str(simulation_db.STATIC_FOLDER), ) _app.config.update(PROPAGATE_EXCEPTIONS=True, ) _app.sirepo_db_dir = cfg.db_dir _app.sirepo_uwsgi = uwsgi http_reply.init_by_server(_app) simulation_db.init_by_server(_app) uri_router.init(_app) for e, _ in simulation_db.SCHEMA_COMMON['customErrors'].items(): _app.register_error_handler(int(e), _handle_error) runner.init(_app, use_reloader) return _app