# This file is sourced by "exec(open(..." from wcs.settings

import os

PROJECT_NAME = 'wcs'
WCS_MANAGE_COMMAND = '/usr/bin/wcs-manage'

#
# hobotization
#
with open('/usr/lib/hobo/debian_config_common.py') as fd:
    exec(fd.read())  # noqa pylint: disable=exec-used

# and some hobo parts that are specific to w.c.s.
TEMPLATES = TEMPLATES  # noqa pylint: disable=undefined-variable,self-assigning-variable
TEMPLATES[0]['OPTIONS']['context_processors'] = [
    'hobo.context_processors.template_vars',
    'hobo.context_processors.theme_base',
    'hobo.context_processors.user_urls',
] + TEMPLATES[0]['OPTIONS']['context_processors']

MIDDLEWARE = (
    'hobo.middleware.utils.StoreRequestMiddleware',
    'hobo.middleware.xforwardedfor.XForwardedForMiddleware',
    'wcs.middleware.PublisherInitialisationMiddleware',
    'hobo.middleware.VersionMiddleware',  # /__version__
    'hobo.middleware.cors.CORSMiddleware',
) + MIDDLEWARE  # noqa pylint: disable=used-before-assignment

# Remove later declaration of PublisherInitialisationMiddleware
MIDDLEWARE = list(MIDDLEWARE)
pub_init_mid_idx = MIDDLEWARE.index('wcs.middleware.PublisherInitialisationMiddleware', 3)
MIDDLEWARE.pop(pub_init_mid_idx)

CACHES = {
    'default': {
        'BACKEND': 'wcs.cache.WcsTenantCache',
        # add a real Django cache backend, with its parameters if needed
        'REAL_BACKEND': 'django.core.cache.backends.memcached.PyMemcacheCache',
        'LOCATION': '127.0.0.1:11211',
    }
}

# don't rely on hobo logging as it requires hobo multitenant support.
LOGGING = {}
LOGGING_CONFIG = None

#
# local settings
#
with open(os.path.join(ETC_DIR, 'settings.py')) as fd:  # noqa pylint: disable=undefined-variable
    exec(fd.read())  # noqa pylint: disable=exec-used

# run additional settings snippets
with open('/usr/lib/hobo/debian_config_settings_d.py') as fd:
    exec(fd.read())  # noqa pylint: disable=exec-used
