-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathconfig.py
63 lines (56 loc) · 2.71 KB
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
###################################################################################
#
# Copyright (c) 2021 Cyril MORISSE (@cmorisse)
#
# This file is part of Inouk Session Store
# (see https://gitub.com/cmorisse/inouk_session_store).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
###################################################################################
import logging
import timeit
import os
_logger = logging.getLogger("InoukSessionStore")
ENV_VARS = None
INOUK_SESSION_STORE_DATABASE = None # Allowed values: 'undefined', 'postgres' or 'redis'
INOUK_SESSION_STORE_REDIS = None
INOUK_SESSION_STORE_DBNAME = None
INOUK_SESSION_STORE_DBTABLE = None
INOUK_SESSION_STORE_DEBUG = False
def load_env_vars():
global ENV_VARS
global INOUK_SESSION_STORE_DATABASE
global INOUK_SESSION_STORE_REDIS
global INOUK_SESSION_STORE_DBNAME
global INOUK_SESSION_STORE_DBTABLE
global INOUK_SESSION_STORE_DEBUG
if ENV_VARS is None:
INOUK_SESSION_STORE_DATABASE = os.environ.get('INOUK_SESSION_STORE', 'undefined').lower() in ('postgres', 'postgresql',)
INOUK_SESSION_STORE_REDIS = os.environ.get('INOUK_SESSION_STORE', 'undefined').lower()=='redis'
INOUK_SESSION_STORE_DBNAME = os.environ.get('INOUK_SESSION_STORE_DBNAME', 'inouk_session_store').lower()
INOUK_SESSION_STORE_DBTABLE = os.environ.get('INOUK_SESSION_STORE_DBTABLE', 'odoo_sessions').lower()
INOUK_SESSION_STORE_DEBUG = os.environ.get('INOUK_SESSION_STORE_DEBUG', "0").lower() in ['yes', 'true', '1', 'y']
ENV_VARS = {
'INOUK_SESSION_STORE_DATABASE': INOUK_SESSION_STORE_DATABASE,
'INOUK_SESSION_STORE_REDIS': INOUK_SESSION_STORE_REDIS,
'INOUK_SESSION_STORE_DBNAME': INOUK_SESSION_STORE_DBNAME,
'INOUK_SESSION_STORE_DBTABLE': INOUK_SESSION_STORE_DBTABLE,
'INOUK_SESSION_STORE_DEBUG': INOUK_SESSION_STORE_DEBUG
}
_logger.info("inouk_session_store params loaded from ENV VARs.")
_logger.info("inouk_session_store params: %s", ENV_VARS)
return ENV_VARS
if ENV_VARS is None:
load_env_vars()