Files
boehmitools-training/plugins/trainingsplan/backend.py
T
2026-09-01 14:57:28 +02:00

27 lines
758 B
Python

# -*- coding: utf-8 -*-
"""Plugin-Adapter fuer das Trainingsplan-Backend."""
from __future__ import annotations
import os
from a2wsgi import WSGIMiddleware
from core.loader import load_module
def create_app(ctx):
# app.py liest DATA_DIR beim Import und legt dort den ersten Plan an.
previous = os.environ.get("DATA_DIR")
os.environ["DATA_DIR"] = str(ctx.data_dir)
try:
module = load_module(ctx.path("app.py"), f"btp_{ctx.id}_app")
finally:
if previous is None:
os.environ.pop("DATA_DIR", None)
else:
os.environ["DATA_DIR"] = previous
# Flask erzeugt seine URLs anhand von SCRIPT_NAME; a2wsgi uebernimmt dafuer
# den root_path des Mounts.
return WSGIMiddleware(module.app)