# -*- coding: utf-8 -*-
import os, logging

BASE_DIR = os.path.dirname(os.path.abspath(__file__)).rstrip("/")+"/"
BASE_URL = '%(base_url)s'
WEB_URL = '%(web_url)s'
STATIC_URL = BASE_URL + 'static/site/'

DEBUG = True

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.%(db_engine)s', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': '%(db_name)s',                      # Or path to database file if using sqlite3.
        # The following settings are not used with sqlite3:
        'USER': '%(db_user)s',
        'PASSWORD': '%(db_password)s',
        'HOST': '%(db_host)s',                      # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.
        'PORT': '%(db_port)d',                      # Set to empty string for default.
    }
}

HAYSTACK_CONNECTIONS = {
    'default': {
        'ENGINE': 'egonomy.search_indexes.backends.elasticsearch_backend.ElasticsearchSearchEngine',
        'URL': '%(haystack_url)s',
        'INDEX_NAME': '%(haystack_index)s',
    },
}

CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
#        'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
#        'LOCATION': 'unix:/var/run/memcached/memcached.socket',
#        'KEY_PREFIX': 'ldt',
    }
}

# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# In a Windows environment this must be set to your system time zone.
TIME_ZONE = 'Europe/Paris'

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'fr-fr'

SITE_ID = 1

BASE_STATIC_ROOT = os.path.abspath(BASE_DIR + "../../web/static/").rstrip("/")+"/"
BASE_STATIC_URL = WEB_URL + BASE_URL + 'static/'

# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/var/www/example.com/media/"
MEDIA_ROOT = BASE_STATIC_ROOT + "media/"

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://example.com/media/", "http://media.example.com/"
MEDIA_URL = BASE_STATIC_URL + "media/"

# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/var/www/example.com/static/"
STATIC_ROOT = BASE_STATIC_ROOT + "site/"

# URL prefix for static files.
# Example: "http://example.com/static/", "http://static.example.com/"
STATIC_URL = BASE_STATIC_URL + "site/"


# Make this unique, and don't share it with anybody.
SECRET_KEY = '%(secret_key)s'

#LOG_FILE = os.path.abspath(os.path.join(BASE_DIR,"../../run/log/log.txt"))
LOG_FILE = '%(log_file)s'
LOG_LEVEL = logging.DEBUG
# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error when DEBUG=False.
# See http://docs.djangoproject.com/en/dev/topics/logging for
# more details on how to customize your logging configuration.
LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'filters': {
        'require_debug_false': {
            '()': 'django.utils.log.RequireDebugFalse'
        }
    },    
    'formatters' : {
        'simple' : {
            'format': "%(asctime)s - %(levelname)s : %(message)s",
        },
        'semi-verbose': {
            'format': '%(levelname)s %(asctime)s %(module)s %(message)s'
        },                    
    },
    'handlers': {
        'mail_admins': {
            'level': 'ERROR',
            'filters': ['require_debug_false'],
            'class': 'django.utils.log.AdminEmailHandler'
        },
        'stream_to_console': {
            'level': LOG_LEVEL,
            'class': 'logging.StreamHandler'
        },
        'file': {
            'level': LOG_LEVEL,
            'class': 'logging.FileHandler',
            'filename': LOG_FILE,
            'formatter': 'semi-verbose',
        },
    },
    'loggers': {
        'django.db.backends':{
            'handlers': ['file'],
            'level': LOG_LEVEL,
            'propagate': True,
        },                
        'django.request': {
            'handlers': ['file'],
            'level': LOG_LEVEL,
            'propagate': True,
        },
        'egonomy': {
            'handlers': ['file'],
            'level': LOG_LEVEL,
            'propagate': True,
        },
    }
}

IMAGES_PER_PAGE = 32

BATIK_RASTERIZER_PATH = "path/to/batik-rasterizer.jar"
BATIK_RASTERIZER_TEMP_FOLDER = "path/to/tmp_folder"

SENSEETIVE_API_URL = "http://url/to/senseetive/api"
SENSEETIVE_API_USER = "user"
SENSEETIVE_API_PASSWORD = "pwd"
SENSEETIVE_API_TENANT = "projectX"

ACCOUNT_ACTIVATION_DAYS = 7 # If you want to change settings

EMAIL_USE_TLS = %(email_use_tls)s
EMAIL_HOST = '%(email_host)s'
EMAIL_HOST_USER = '%(email_host_user)s'
EMAIL_HOST_PASSWORD = '%(email_host_password)s'
EMAIL_PORT = %(email_port)d 
