From 868ca224f333e98d94722dfe3a7884345f715a22 Mon Sep 17 00:00:00 2001 From: Thomas Schneider <thomas@fsmpi.rwth-aachen.de> Date: Fri, 13 Dec 2024 15:50:27 +0100 Subject: [PATCH] Allow overriding instance directory location --- docs/installation.rst | 10 ++++++---- schilder2000/__init__.py | 7 ++++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/docs/installation.rst b/docs/installation.rst index 09d3ea1..f88745e 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -150,10 +150,12 @@ Configuration ------------- Configuration and runtime data is stored in the instance directory. For -container installs, this is ``/usr/local/var/schilder2000-instance/``. -For package installs, this is ``{{ python prefix }}/var/schilder2000-instance``; -if in doubt, try to run ``flask -A schilder2000``, the error should tell you -where it expects the instance directory. +container installs, this is ``/usr/local/var/schilder2000-instance/``. For +package installs, this defaults to ``{{ python prefix +}}/var/schilder2000-instance``; if in doubt, try to run ``flask -A +schilder2000``, the error should tell you where it expects the instance +directory. To override, specify an *absolute* path in the +``SCHILDER2000_INSTANCE_PATH`` environment variable. Example config and data is located in the ``examples`` directory. The templates there get their footer text and logo from the application config and should also diff --git a/schilder2000/__init__.py b/schilder2000/__init__.py index ebbb813..0d3a4a2 100644 --- a/schilder2000/__init__.py +++ b/schilder2000/__init__.py @@ -1,3 +1,4 @@ +import os from pathlib import Path from flask_multipass import Multipass @@ -15,7 +16,11 @@ multipass = Multipass() def create_app(): - app = Flask(__name__, instance_relative_config=True) + app = Flask( + __name__, + instance_path=os.getenv("SCHILDER2000_INSTANCE_PATH"), + instance_relative_config=True, + ) app.config.from_pyfile("config/config.py") app.cli.add_command(cli.alembic) -- GitLab