From f42d553ab0a4fe74b10b6b5ef1ed17a2e1eb9412 Mon Sep 17 00:00:00 2001 From: Sandro Mani Date: Wed, 3 Jul 2024 16:40:34 +0200 Subject: [PATCH] Allow specifying a curstom tenant_path_prefix as env --- qwc_services_core/tenant_handler.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/qwc_services_core/tenant_handler.py b/qwc_services_core/tenant_handler.py index e659e59..70a5cc8 100644 --- a/qwc_services_core/tenant_handler.py +++ b/qwc_services_core/tenant_handler.py @@ -164,7 +164,7 @@ def __init__(self, app, _header=None, _ignore_default=None): self.app = app self.tenant_handler = TenantHandlerBase() self.service_prefix = os.environ.get( - 'QWC_SERVICE_PREFIX', '/').rstrip('/') + '/' + 'QWC_SERVICE_PREFIX', '/').rstrip('/') def __call__(self, environ, start_response): # environ in request http://localhost:9090/base/pages/test.html?arg=1 @@ -182,7 +182,7 @@ def __call__(self, environ, start_response): ): # add tenant path prefix for multitenancy # NOTE: skipped if tenant already in path when using TENANT_URL_RE - prefix = self.service_prefix + tenant + prefix = os.environ.get('TENANT_PATH_PREFIX', '@service_prefix@/@tenant@').replace('@service_prefix@', self.service_prefix).replace('@tenant@', tenant) environ['SCRIPT_NAME'] = prefix + environ.get( 'SCRIPT_NAME', '') return self.app(environ, start_response) @@ -200,9 +200,9 @@ def __init__(self, environ): def tenant_path_prefix(self): """Tenant path prefix /map/org1 ("$QWC_SERVICE_PREFIX/$TENANT")""" if self.is_multi(): - return self.service_prefix + self.tenant() + return os.environ.get('TENANT_PATH_PREFIX', '@service_prefix@/@tenant@').replace('@service_prefix@', self.service_prefix).replace('@tenant@', self.tenant()) else: - return self.service_prefix + return self.service_prefix + "/" def get_cookie_path(self, app): # https://flask.palletsprojects.com/en/1.1.x/api/#flask.sessions.SessionInterface.get_cookie_path