Blame view

resources/pdc_config.py 3.78 KB
06a8b735   hitier   Exit error if wro...
1
import sys
2d4a51a9   hitier   gitignore
2
import os
3f07ad83   hitier   Add latest config...
3

06a8b735   hitier   Exit error if wro...
4
5
6
7
8
9
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)
2d4a51a9   hitier   gitignore
10

2d4a51a9   hitier   gitignore
11

d086fdc1   hitier   Main config file ...
12
13
14
15
#
# SQLALCHEMY_DATABASE_URI will default to 'sqlite:///:memory:' if not set
#

2d4a51a9   hitier   gitignore
16
class Config(object):
2795e037   hitier   Update configurat...
17
    SECRET_KEY = 'dev'
3f07ad83   hitier   Add latest config...
18
    PDC_ROOT_DIR = os.path.abspath(os.path.dirname(__file__))
d086fdc1   hitier   Main config file ...
19

f18213fd   hitier   New PDC_SITE_CLAS...
20
21
    # Please change the following to fit you own site parameters
    #
880e8a55   hitier   New config vars u...
22
    PDC_APP_NAME = 'Plan de Charge'
b4ff40eb   hitier   More comments in ...
23
24
25
    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 )
3f07ad83   hitier   Add latest config...
26
    PDC_LOGS_DIR = os.path.join(PDC_ROOT_DIR, 'logs')
9b19aa41   hitier   fix default confi...
27
    PDC_LOGS_FILE = os.path.join(PDC_LOGS_DIR, 'pdc.log')
3f07ad83   hitier   Add latest config...
28
    PDC_RESOURCES_DIR = os.path.join(PDC_ROOT_DIR, 'resources')
880e8a55   hitier   New config vars u...
29

3b0d5feb   hitier   New Site_Login ca...
30
    # Uncomment for role access control
b4ff40eb   hitier   More comments in ...
31
    #
3b0d5feb   hitier   New Site_Login ca...
32
33
34
35
36
37
    #   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
b4ff40eb   hitier   More comments in ...
38
    #
3b0d5feb   hitier   New Site_Login ca...
39
    #   if True, will force login access on any site page 
3f07ad83   hitier   Add latest config...
40
    #   note that this doesnt disable the @login_required 
3b0d5feb   hitier   New Site_Login ca...
41
42
    #
    # SITE_LOGIN = False
08d06308   hitier   New ROLE_DISABLED...
43

f18213fd   hitier   New PDC_SITE_CLAS...
44
45
    #
    # No need to Edit below
b4ff40eb   hitier   More comments in ...
46
    # ( but keep reading )
f18213fd   hitier   New PDC_SITE_CLAS...
47
48
    #

7e08aa0c   hitier   Allow force loggi...
49
50
51
52
53
54
    # 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

9b19aa41   hitier   fix default confi...
55
56
    SQLALCHEMY_TRACK_MODIFICATIONS = False

d086fdc1   hitier   Main config file ...
57
58
59
60
61
    # 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 \
3f07ad83   hitier   Add latest config...
62
                                  'sqlite:///' + os.path.join(PDC_ROOT_DIR, 'pdc.db')
2795e037   hitier   Update configurat...
63

21724174   hitier   Fix mysql_lesia_u...
64
65
66
67
    try:
        LESIA_AGENTS_DB_URI = mysql_lesia_uri
    except NameError:
        LESIA_AGENTS_DB_URI = os.environ.get('LESIA_AGENTS_DB_URI') or \
3f07ad83   hitier   Add latest config...
68
                              'sqlite:///' + os.path.join(PDC_ROOT_DIR, 'lesia.db')
21724174   hitier   Fix mysql_lesia_u...
69

3f07ad83   hitier   Add latest config...
70
71
72
    # 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:
2d4a51a9   hitier   gitignore
73
74
75
        VERSION = version_file.read().strip()


b4ff40eb   hitier   More comments in ...
76
77
# Production configuration
#
2d4a51a9   hitier   gitignore
78
79
80
81
82
class ProdConfig(Config):
    TESTING = False
    DEBUG = False


b4ff40eb   hitier   More comments in ...
83
84
# Development configuration
#
2d4a51a9   hitier   gitignore
85
86
class DevConfig(Config):
    DEBUG = True
b4ff40eb   hitier   More comments in ...
87

d086fdc1   hitier   Main config file ...
88
89
90
91
92
    # 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 \
3f07ad83   hitier   Add latest config...
93
                                  'sqlite:///' + os.path.join(Config.PDC_ROOT_DIR, 'pdc-dev.db')
08d06308   hitier   New ROLE_DISABLED...
94
95
96
97
    # ignores @login_required decorator
    LOGIN_DISABLED = True
    # ignores @role_required decorator
    ROLE_DISABLED = True
2d4a51a9   hitier   gitignore
98
99


b4ff40eb   hitier   More comments in ...
100
101
# Testing configuration
#
2d4a51a9   hitier   gitignore
102
103
104
class TestConfig(Config):
    TESTING = True
    DEBUG = True
08d06308   hitier   New ROLE_DISABLED...
105
    PDC_LOGS_LEVEL = 'ERROR'  # choose within  DEBUG, INFO, WARN, ERROR ( more levels in logging module )
b4ff40eb   hitier   More comments in ...
106

d086fdc1   hitier   Main config file ...
107
108
109
110
111
    # 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 \
3f07ad83   hitier   Add latest config...
112
                                  'sqlite:///' + os.path.join(Config.PDC_ROOT_DIR, 'pdc-test.db')
2d4a51a9   hitier   gitignore
113
    # ignores @login_required decorator
08d06308   hitier   New ROLE_DISABLED...
114
115
116
    LOGIN_DISABLED = True
    # ignores @role_required decorator
    ROLE_DISABLED = True
2d4a51a9   hitier   gitignore
117

2795e037   hitier   Update configurat...
118
# vim: tw=0