# -*- coding: utf-8 -*-
"""
Global configuration file for TG2-specific settings in Monkey.

This file complements development/deployment.ini.

Please note that **all the argument values are strings**. If you want to
convert them into boolean, for example, you should use the
:func:`paste.deploy.converters.asbool` function, as in::
    
    from paste.deploy.converters import asbool
    setting = asbool(global_conf.get('the_setting'))
 
"""

from tg.configuration import AppConfig
from tg.util import Bunch

import monkey
from monkey import model
from monkey.lib import app_globals, helpers 

base_config = AppConfig()
base_config.renderers = []

base_config.package = monkey

#Set the default renderer
base_config.default_renderer = 'genshi'
base_config.renderers.append('genshi')
base_config.renderers.append('mako')

#Configure the base SQLALchemy Setup
base_config.use_sqlalchemy = True
base_config.model = monkey.model
base_config.DBSession = monkey.model.DBSession

# Configure the authentication backend
base_config.auth_backend = None
base_config.baz_auth = Bunch()
base_config.baz_auth.dbsession = model.DBSession
base_config.baz_auth.cookie_secret = 'tmhijvhkpdpwmhuv'

# You may optionally define a page where you want users to be redirected to
# on login:
base_config.baz_auth.post_login_url = '/post_login'

# You may optionally define a page where you want users to be redirected to
# on logout:
base_config.baz_auth.post_logout_url = '/post_logout'

# We use Bazki's transaction manager, not TurboGears's
base_config.use_transaction_manager = False

# Thunk this so that the config's available when controllers get imported
def init():
    from bazki import turbogears as baztg
    baztg.init()

base_config.call_on_startup.append(init)

import os
import bazsvn.custom
bazsvn.custom.REPOSITORY = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), 'repository')
