pdc_config.py
3.78 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import sys
import os
try:
from db_config import *
except ImportError:
sys.stderr.write("ERROR: Please set a db_config.py file in you PYTHON_PATH\n")
sys.stderr.write("ERROR: See INSTALL.md for more info\n")
sys.exit(-1)
#
# SQLALCHEMY_DATABASE_URI will default to 'sqlite:///:memory:' if not set
#
class Config(object):
SECRET_KEY = 'dev'
PDC_ROOT_DIR = os.path.abspath(os.path.dirname(__file__))
# Please change the following to fit you own site parameters
#
PDC_APP_NAME = 'Plan de Charge'
PDC_SITE_NAME = 'NO_SITE' # choose among DEV, IRAP, LESIA, LAM ... will display on page's title
PDC_SITE_CLASS = 'public-icon' # choose among admin-icon, public-icon, dev-icon, see more in app/static/style.css
PDC_LOGS_LEVEL = 'ERROR' # choose within DEBUG, INFO, WARN, ERROR ( more in the python logging module )
PDC_LOGS_DIR = os.path.join(PDC_ROOT_DIR, 'logs')
PDC_LOGS_FILE = os.path.join(PDC_LOGS_DIR, 'pdc.log')
PDC_RESOURCES_DIR = os.path.join(PDC_ROOT_DIR, 'resources')
# Uncomment for role access control
#
# if True, will disable any role control on routes
# note that this doesnt disable the @login_required
#
# ROLE_DISABLED = False
# Uncomment for site access control
#
# if True, will force login access on any site page
# note that this doesnt disable the @login_required
#
# SITE_LOGIN = False
#
# No need to Edit below
# ( but keep reading )
#
# You can force logging to stdout in production environment
# (make sure your httpd/wsgi server can redirect to log files)
LOG_TO_STDOUT = os.environ.get('LOG_TO_STDOUT')
if LOG_TO_STDOUT and LOG_TO_STDOUT.upper() == "true".upper():
LOG_TO_STDOUT = True
SQLALCHEMY_TRACK_MODIFICATIONS = False
# Trying to set specific db uri from ./db_config.py
try:
SQLALCHEMY_DATABASE_URI = sqlalchemy_database_uri
except NameError:
SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL') or \
'sqlite:///' + os.path.join(PDC_ROOT_DIR, 'pdc.db')
try:
LESIA_AGENTS_DB_URI = mysql_lesia_uri
except NameError:
LESIA_AGENTS_DB_URI = os.environ.get('LESIA_AGENTS_DB_URI') or \
'sqlite:///' + os.path.join(PDC_ROOT_DIR, 'lesia.db')
# TODO: to be set in a app_init() method so we can see if we are prod, dev or testing,
# then set the VERSION accordingly
with open(os.path.join(PDC_ROOT_DIR, 'VERSION.txt')) as version_file:
VERSION = version_file.read().strip()
# Production configuration
#
class ProdConfig(Config):
TESTING = False
DEBUG = False
# Development configuration
#
class DevConfig(Config):
DEBUG = True
# Trying to set specific db uri from ./db_config.py
try:
SQLALCHEMY_DATABASE_URI = sqlalchemy_devdb_uri
except NameError:
SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL') or \
'sqlite:///' + os.path.join(Config.PDC_ROOT_DIR, 'pdc-dev.db')
# ignores @login_required decorator
LOGIN_DISABLED = True
# ignores @role_required decorator
ROLE_DISABLED = True
# Testing configuration
#
class TestConfig(Config):
TESTING = True
DEBUG = True
PDC_LOGS_LEVEL = 'INFO' # choose within DEBUG, INFO, WARN, ERROR ( more levels in logging module )
# Trying to set specific db uri from ./db_config.py
try:
SQLALCHEMY_DATABASE_URI = sqlalchemy_testdb_uri
except NameError:
SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL') or \
'sqlite:///' + os.path.join(Config.PDC_ROOT_DIR, 'pdc-test.db')
# ignores @login_required decorator
LOGIN_DISABLED = True
# ignores @role_required decorator
ROLE_DISABLED = True
# vim: tw=0