def init_extensions(self): """Initialize flask extensions, helpers and services. """ self.init_debug_toolbar() redis.Extension(self) extensions.mail.init_app(self) extensions.upstream_info.extension.init_app(self) actions.init_app(self) from abilian.core.jinjaext import DeferredJS DeferredJS(self) # auth_service installs a `before_request` handler (actually it's # flask-login). We want to authenticate user ASAP, so that sentry and logs # can report which user encountered any error happening later, in particular # in a before_request handler (like csrf validator) auth_service.init_app(self) # webassets self._setup_asset_extension() self._register_base_assets() # Babel (for i18n) babel = abilian.i18n.babel # Temporary (?) workaround babel.locale_selector_func = None babel.timezone_selector_func = None babel.init_app(self) babel.add_translations('wtforms', translations_dir='locale', domain='wtforms') babel.add_translations('abilian') babel.localeselector(abilian.i18n.localeselector) babel.timezoneselector(abilian.i18n.timezoneselector) # Flask-Migrate Migrate(self, self.db) # CSRF by default if self.config.get('CSRF_ENABLED'): extensions.csrf.init_app(self) self.extensions['csrf'] = extensions.csrf extensions.abilian_csrf.init_app(self) self.register_blueprint(csrf.blueprint) # images blueprint from .web.views.images import blueprint as images_bp self.register_blueprint(images_bp) # Abilian Core services security_service.init_app(self) repository_service.init_app(self) session_repository_service.init_app(self) audit_service.init_app(self) index_service.init_app(self) activity_service.init_app(self) preferences_service.init_app(self) conversion_service.init_app(self) vocabularies_service.init_app(self) antivirus.init_app(self) from .web.preferences.user import UserPreferencesPanel preferences_service.register_panel(UserPreferencesPanel(), self) from .web.coreviews import users self.register_blueprint(users.bp) # Admin interface Admin().init_app(self) # Celery async service # this allows all shared tasks to use this celery app celery_app = self.extensions['celery'] = self.celery_app_cls() # force reading celery conf now - default celery app will # also update our config with default settings celery_app.conf # noqa celery_app.set_default() # dev helper if self.debug: # during dev, one can go to /http_error/403 to see rendering of 403 http_error_pages = Blueprint('http_error_pages', __name__) @http_error_pages.route('/<int:code>') def error_page(code): """ Helper for development to show 403, 404, 500...""" abort(code) self.register_blueprint(http_error_pages, url_prefix='/http_error')
def init_extensions(self): """Initialize flask extensions, helpers and services.""" extensions.redis.init_app(self) extensions.mail.init_app(self) extensions.deferred_js.init_app(self) extensions.upstream_info.extension.init_app(self) actions.init_app(self) # auth_service installs a `before_request` handler (actually it's # flask-login). We want to authenticate user ASAP, so that sentry and # logs can report which user encountered any error happening later, # in particular in a before_request handler (like csrf validator) auth_service.init_app(self) # webassets self.setup_asset_extension() self.register_base_assets() # Babel (for i18n) babel = abilian.i18n.babel # Temporary (?) workaround babel.locale_selector_func = None babel.timezone_selector_func = None babel.init_app(self) babel.add_translations("wtforms", translations_dir="locale", domain="wtforms") babel.add_translations("abilian") babel.localeselector(abilian.i18n.localeselector) babel.timezoneselector(abilian.i18n.timezoneselector) # Flask-Migrate Migrate(self, db) # CSRF by default if self.config.get("WTF_CSRF_ENABLED"): extensions.csrf.init_app(self) self.extensions["csrf"] = extensions.csrf extensions.abilian_csrf.init_app(self) self.register_blueprint(csrf.blueprint) # images blueprint from .web.views.images import blueprint as images_bp self.register_blueprint(images_bp) # Abilian Core services security_service.init_app(self) repository_service.init_app(self) session_repository_service.init_app(self) audit_service.init_app(self) index_service.init_app(self) activity_service.init_app(self) preferences_service.init_app(self) conversion_service.init_app(self) vocabularies_service.init_app(self) antivirus.init_app(self) from .web.preferences.user import UserPreferencesPanel preferences_service.register_panel(UserPreferencesPanel(), self) from .web.coreviews import users self.register_blueprint(users.blueprint) # Admin interface Admin().init_app(self) # Celery async service # this allows all shared tasks to use this celery app if getattr(self, "celery_app_cls", None): celery_app = self.extensions["celery"] = self.celery_app_cls() # force reading celery conf now - default celery app will # also update our config with default settings celery_app.conf # noqa celery_app.set_default() # dev helper if self.debug: # during dev, one can go to /http_error/403 to see rendering of 403 http_error_pages = Blueprint("http_error_pages", __name__) @http_error_pages.route("/<int:code>") def error_page(code): """Helper for development to show 403, 404, 500...""" abort(code) self.register_blueprint(http_error_pages, url_prefix="/http_error")
def init_extensions(self): """ Initializes flask extensions, helpers and services. """ self.init_debug_toolbar() redis.Extension(self) extensions.mail.init_app(self) extensions.upstream_info.extension.init_app(self) actions.init_app(self) from abilian.core.jinjaext import DeferredJS DeferredJS(self) # auth_service installs a `before_request` handler (actually it's # flask-login). We want to authenticate user ASAP, so that sentry and logs # can report which user encountered any error happening later, in particular # in a before_request handler (like csrf validator) auth_service.init_app(self) # webassets self._setup_asset_extension() self._register_base_assets() # Babel (for i18n) abilian.i18n.babel.init_app(self) abilian.i18n.babel.add_translations('wtforms', translations_dir='locale', domain='wtforms') abilian.i18n.babel.add_translations('abilian') abilian.i18n.babel.localeselector(abilian.i18n.localeselector) abilian.i18n.babel.timezoneselector(abilian.i18n.timezoneselector) # Flask-Migrate Migrate(self, self.db) # CSRF by default if self.config.get('CSRF_ENABLED'): extensions.csrf.init_app(self) self.extensions['csrf'] = extensions.csrf extensions.abilian_csrf.init_app(self) self.register_blueprint(csrf.blueprint) # images blueprint from .web.views.images import blueprint as images_bp self.register_blueprint(images_bp) # Abilian Core services security_service.init_app(self) repository_service.init_app(self) session_repository_service.init_app(self) audit_service.init_app(self) index_service.init_app(self) activity_service.init_app(self) preferences_service.init_app(self) conversion_service.init_app(self) vocabularies_service.init_app(self) antivirus.init_app(self) from .web.preferences.user import UserPreferencesPanel preferences_service.register_panel(UserPreferencesPanel(), self) from .web.coreviews import users self.register_blueprint(users.bp) # Admin interface Admin().init_app(self) # Celery async service # this allows all shared tasks to use this celery app celery_app = self.extensions['celery'] = self.celery_app_cls() celery_app.conf # force reading celery conf now - default celery app will # also update our config with default settings celery_app.set_default() # dev helper if self.debug: # during dev, one can go to /http_error/403 to see rendering of 403 http_error_pages = Blueprint('http_error_pages', __name__) @http_error_pages.route('/<int:code>') def error_page(code): """ Helper for development to show 403, 404, 500...""" abort(code) self.register_blueprint(http_error_pages, url_prefix='/http_error')
def init_extensions(self): """ Initializes flask extensions, helpers and services. """ self.init_debug_toolbar() extensions.mail.init_app(self) actions.init_app(self) from abilian.core.jinjaext import DeferredJS DeferredJS(self) # webassets self._setup_asset_extension() self._register_base_assets() # Babel (for i18n) abilian.i18n.babel.init_app(self) abilian.i18n.babel.add_translations('abilian') abilian.i18n.babel.localeselector(get_locale) abilian.i18n.babel.timezoneselector(get_timezone) # Flask-Migrate Migrate(self, self.db) # CSRF by default if self.config.get('CSRF_ENABLED'): extensions.csrf.init_app(self) self.extensions['csrf'] = extensions.csrf self.register_blueprint(csrf.blueprint) # Abilian Core services auth_service.init_app(self) security_service.init_app(self) repository_service.init_app(self) session_repository_service.init_app(self) audit_service.init_app(self) index_service.init_app(self) activity_service.init_app(self) preferences_service.init_app(self) conversion_service.init_app(self) from .web.preferences.user import UserPreferencesPanel preferences_service.register_panel(UserPreferencesPanel(), self) from .web.coreviews import users self.register_blueprint(users.bp) # Admin interface Admin().init_app(self) # Celery async service extensions.celery.config_from_object(self.config) # dev helper if self.debug: # during dev, one can go to /http_error/403 to see rendering of 403 http_error_pages = Blueprint('http_error_pages', __name__) @http_error_pages.route('/<int:code>') def error_page(code): """ Helper for development to show 403, 404, 500...""" abort(code) self.register_blueprint(http_error_pages, url_prefix='/http_error')