fmartingr.com-legacy/fmartingrcom/settings/configfile.py

47 lines
1004 B
Python

import os
import sys
import dj_database_url
import toml
from .base import *
this_module = sys.modules[__name__]
# Read configfile
with open(os.environ['APP_CONFIGFILE']) as conffile:
config = toml.loads(conffile.read())
# Installed Apps
INSTALLED_APPS += tuple(config['global']['installed_apps'])
# Database
DATABASES = {
'default': dj_database_url.parse(config['global']['database_url'])
}
SECRET_KEY = open(config['global']['secret_key']).read().strip()
# Overwrite values
for key, value in config['overwrite'].iteritems():
setattr(this_module, key.upper(), value)
# Logging
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'file': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'filename': config['log']['logfile'],
},
},
'loggers': {
'django.request': {
'handlers': ['file'],
'level': 'DEBUG',
'propagate': True,
},
},
}