From 2b9e8fa273ceee19c59139e8744bb3a905c33e7b Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Sat, 9 Sep 2023 05:02:05 +0200 Subject: [PATCH] WebHost: flask caching doesn't do lazy init anymore (#2155) --- WebHost.py | 3 ++- WebHostLib/__init__.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/WebHost.py b/WebHost.py index 45d017cf..36645ad2 100644 --- a/WebHost.py +++ b/WebHost.py @@ -14,7 +14,7 @@ import settings Utils.local_path.cached_path = os.path.dirname(__file__) or "." # py3.8 is not abs. remove "." when dropping 3.8 -from WebHostLib import register, app as raw_app +from WebHostLib import register, cache, app as raw_app from waitress import serve from WebHostLib.models import db @@ -40,6 +40,7 @@ def get_app(): app.config["HOST_ADDRESS"] = Utils.get_public_ipv4() logging.info(f"HOST_ADDRESS was set to {app.config['HOST_ADDRESS']}") + cache.init_app(app) db.bind(**app.config["PONY"]) db.generate_mapping(create_tables=True) return app diff --git a/WebHostLib/__init__.py b/WebHostLib/__init__.py index a59e3aa5..441f3272 100644 --- a/WebHostLib/__init__.py +++ b/WebHostLib/__init__.py @@ -49,11 +49,11 @@ app.config["PONY"] = { 'create_db': True } app.config["MAX_ROLL"] = 20 -app.config["CACHE_TYPE"] = "flask_caching.backends.SimpleCache" +app.config["CACHE_TYPE"] = "SimpleCache" app.config["JSON_AS_ASCII"] = False app.config["HOST_ADDRESS"] = "" -cache = Cache(app) +cache = Cache() Compress(app)