pdc_config.py 1.5 KB
import os
from db_config import *

root_dir = os.path.abspath(os.path.dirname(__file__))


#
# SQLALCHEMY_DATABASE_URI will default to 'sqlite:///:memory:' if not set
#

class Config(object):
    SECRET_KEY = 'dev'
    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(root_dir, 'pdc_app.db')

    with open(os.path.join(root_dir, 'VERSION.txt')) as version_file:
        VERSION = version_file.read().strip()


class ProdConfig(Config):
    TESTING = False
    DEBUG = False


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(root_dir, 'pdc_app_dev.db')


class TestConfig(Config):
    TESTING = True
    DEBUG = True
    # 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(root_dir, 'pdc_app_test.db')
    # ignores @login_required decorator
    # LOGIN_DISABLED = True

# vim: tw=0