from pyramid.config import Configurator
from pyramid.i18n import TranslationStringFactory

from ringo.lib.sql.db import setup_db_session, setup_db_engine
from ringo.model import Base
from ringo.config import setup_modules
from ringo.lib.i18n import translators
from {{package}}.model import extensions

def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    engine = setup_db_engine(settings)
    setup_db_session(engine)
    Base.metadata.bind = engine
    config = Configurator(settings=settings)
    # Include basic ringo configuration.
    config.include('ringo')
    config.include('{{package}}')
    for extension in extensions:
        config.include(extension)
    config.scan()
    return config.make_wsgi_app()

def includeme(config):
    # Now configure the application and optionally overwrite previously
    translators.append(TranslationStringFactory('{{package}}'))
    config.add_translation_dirs('{{package}}:locale/')
    config.add_static_view('{{package}}-static', path='{{package}}:static',
                           cache_max_age=3600)
