a class that represents the extension’s configuration and behavior, with an init_app method to apply the extension instance to the given application instance. 18
version is same as tabler-icons __version__ = "3.3.0" class TablerIcons: def __init__(self, app: Any = None) -> None: if app is not None: self.init_app(app) def init_app(self, app: Flask) -> None: if not hasattr(app, "extensions"): app.extensions = {} app.extensions["tabler_icons"] = self bp = Blueprint( "tabler_icons", __name__, static_folder="static", static_url_path=f"/tabler-icons{app.static_url_path}", template_folder="templates", ) app.register_blueprint(bp) app.jinja_env.globals["tabler_icons"] = self app.config.setdefault("TABLER_ICON_SIZE", 24) 31
key, value in config_binds.items(): engine_options[key] = self._engine_options.copy() if isinstance(value, (str, sa.engine.URL)): engine_options[key]["url"] = value else: engine_options[key].update(value) # Build the engine config for the default bind key. if basic_uri is not None: basic_engine_options["url"] = basic_uri if "url" in basic_engine_options: engine_options.setdefault(None, {}).update(basic_engine_options) if not engine_options: raise RuntimeError( "Either 'SQLALCHEMY_DATABASE_URI' or 'SQLALCHEMY_BINDS' must be set." ) 38
init_app is called again. if engines: for engine in engines.values(): engine.dispose() engines.clear() # Create the metadata and engine for each bind key. for key, options in engine_options.items(): self._make_metadata(key) options.setdefault("echo", echo) options.setdefault("echo_pool", echo) self._apply_driver_defaults(options, app) engines[key] = self._make_engine(key, options, app) if app.config.setdefault("SQLALCHEMY_RECORD_QUERIES", False): from . import record_queries for engine in engines.values(): record_queries._listen(engine) if app.config.setdefault("SQLALCHEMY_TRACK_MODIFICATIONS", False): from . import track_modifications track_modifications._listen(self.session) 39