fmartingr
/
shelfzilla
Archived
1
0
Fork 0

Added settings.configfile

This commit is contained in:
Felipe Martin 2014-05-28 00:06:29 +02:00
parent fa1fdcd5b3
commit 8816d075ca
1 changed files with 93 additions and 0 deletions

View File

@ -0,0 +1,93 @@
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'])
}
# Overwrite values
for key, value in config['overwrite'].iteritems():
setattr(this_module, key.upper(), value)
# Filer
FILER_STORAGES = {
'public': {
'main': {
'ENGINE': 'django.core.files.storage.FileSystemStorage',
'OPTIONS': {
'location': os.path.abspath(
os.path.join(MEDIA_ROOT, 'filer/public/')),
'base_url': '{}files/'.format(config['filer']['base_url']),
},
'UPLOAD_TO': 'shelfzilla.utils.filer_generate_randomized',
'UPLOAD_TO_PREFIX': '',
},
'thumbnails': {
'ENGINE': 'django.core.files.storage.FileSystemStorage',
'OPTIONS': {
'location': os.path.abspath(
os.path.join(MEDIA_ROOT, 'filer/public/')),
'base_url': '{}files/'.format(config['filer']['base_url']),
},
'THUMBNAIL_OPTIONS': {
'base_dir': 'thumbnails',
},
'UPLOAD_TO_PREFIX': '',
},
},
'private': {
'main': {
'ENGINE': 'filer.storage.PrivateFileSystemStorage',
'OPTIONS': {
'location': os.path.abspath(
os.path.join(MEDIA_ROOT, 'filer/private')),
'base_url': '/smedia/private/',
},
'UPLOAD_TO': 'shelfzilla.utils.filer_generate_randomized',
'UPLOAD_TO_PREFIX': '',
},
'thumbnails': {
'ENGINE': 'filer.storage.PrivateFileSystemStorage',
'OPTIONS': {
'location': os.path.abspath(
os.path.join(MEDIA_ROOT, 'filer/private_thumbnails')),
'base_url': '/smedia/private_thumbnails/',
},
'THUMBNAIL_OPTIONS': {},
},
},
}
# 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,
},
},
}