# Initialize App Engine and import the default settings (DB backend, etc.).
# If you want to use a different backend you have to remove all occurences
# of "djangoappengine" from this file.
from djangoappengine.settings_base import *
from private_settings import SECRET_KEY

import os

# Activate django-dbindexer for the default database
DATABASES['native'] = DATABASES['default']
DATABASES['default'] = {'ENGINE': 'dbindexer', 'TARGET': 'native'}
AUTOLOAD_SITECONF = 'indexes'

INSTALLED_APPS = (
#    'django.contrib.admin',
    'django.contrib.contenttypes',
    'django.contrib.auth',
    'django.contrib.sessions',
    'django.contrib.staticfiles',
    'django.contrib.markup',
    'djangotoolbox',
    'autoload',
    'dbindexer',
    "simpleblog.content",

    # djangoappengine should come last, so it can override a few manage.py commands
    'djangoappengine',
)

MIDDLEWARE_CLASSES = [
    # This loads the index definitions, so it has to come first
    'autoload.middleware.AutoloadMiddleware',

    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
]

if not DEBUG:
    # Put the stats middleware after autoload
    MIDDLEWARE_CLASSES.insert(
        1, 'google.appengine.ext.appstats.recording.AppStatsDjangoMiddleware')

TEMPLATE_CONTEXT_PROCESSORS = (
    'django.contrib.auth.context_processors.auth',
    'django.core.context_processors.request',
    'django.core.context_processors.media',
    'django.core.context_processors.static',
)

# This test runner captures stdout and associates tracebacks with their
# corresponding output. Helps a lot with print-debugging.
TEST_RUNNER = 'djangotoolbox.test.CapturingTestSuiteRunner'

TEMPLATE_DIRS = (os.path.join(os.path.dirname(__file__), 'templates'),)

ROOT_URLCONF = 'simpleblog.urls'

if DEBUG:
    STATIC_URL = "/devstatic/"
else:
    STATIC_URL = "/static/"
STATICFILES_DIRS = ("staticfiles", )
STATIC_ROOT = "static_collected"
PRE_DEPLOY_COMMANDS = ("collectstatic", )

LOGIN_URL = "/login"
LOGIN_REDIRECT_URL = "/"
