"""Shared extension instances and accessors. Extensions are created here (unbound to any app) and initialized against the app inside ``create_app()``. This lets blueprints/services import the single shared ``login_manager`` / ``oauth`` without importing ``app`` itself. ``filter_engine`` and ``polling_service`` are accessed lazily so importing this module (or ``app``) has no side effects. """ import logging from flask_login import LoginManager from authlib.integrations.flask_client import OAuth logger = logging.getLogger(__name__) # Flask-Login: bound to the app in create_app(). login_manager = LoginManager() login_manager.login_view = "login" login_manager.login_message = "Please log in to access this page." # Authlib OAuth: bound to the app in create_app(). oauth = OAuth() def get_filter_engine(): """Return the singleton FilterEngine instance (lazy). ``FilterEngine.get_instance()`` is itself a lazy singleton, so this is cheap to call from routes/services. Kept as a function (not a module global) so importing this module never triggers filter-engine init. """ from filter_pipeline import FilterEngine return FilterEngine.get_instance() def get_polling_service(): """Return the shared polling service singleton (lazy import).""" from polling_service import polling_service return polling_service