From 006c1fd567871826e361a6e266d59390466a7e87 Mon Sep 17 00:00:00 2001 From: Mike McLean Date: Dec 05 2024 18:28:09 +0000 Subject: mod_wsgi SetEnv workaround --- diff --git a/mbsweb/ui.py b/mbsweb/ui.py index 43040ec..7d17491 100644 --- a/mbsweb/ui.py +++ b/mbsweb/ui.py @@ -11,6 +11,24 @@ import requests bp = Blueprint('ui', __name__, url_prefix='/mbs-ui') +GOT_ENV_CONFIG = False + + +@bp.before_request +def config_from_env(): + # like util function, but we pull from mod_wsgi request + # we do this because under mod_wsgi, SetEnv values are in the app environ, but not os.environ + global GOT_ENV_CONFIG + if GOT_ENV_CONFIG: + # we only need to check this first pass + return + prefix = 'MBSWEB_' + for key in request.environ: + if key.startswith(prefix): + newkey = key[len(prefix):] + current_app.config[newkey] = request.environ[key] + GOT_ENV_CONFIG = True + def get_module_css_class(module): state = module.get('state_name', 'unknown')