<commit_before>from pyramid.config import Configurator
from sqlalchemy import engine_from_config
from pyramid.authentication import AuthTktAuthenticationPolicy
from pyramid.authorization import ACLAuthorizationPolicy
from pyramid.session import UnencryptedCookieSessionFactoryConfig

from .models import (
    DBSession,
    Base,
    )

from .resources import (
    MapnikRendererFactory
    )

from sqlalchemy_i18n.manager import translation_manager

from .security import (
    RootFactory,
    group_membership,
    )

def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    settings['mako.directories'] = 'osmtm:templates'

    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    Base.metadata.bind = engine

    authn_policy = AuthTktAuthenticationPolicy(
            secret='super_secret',
            callback=group_membership)
    authz_policy = ACLAuthorizationPolicy()
    config = Configurator(settings=settings,
            root_factory=RootFactory,
            authentication_policy=authn_policy,
            authorization_policy=authz_policy)

    session_factory = UnencryptedCookieSessionFactoryConfig('itsasecret')
    config.set_session_factory(session_factory)

    config.add_static_view('static', 'static', cache_max_age=3600)
    config.add_route('home', '/')
    config.add_route('login', '/login')
    config.add_route('logout', '/logout')
    config.add_route('oauth_callback', '/oauth_callback')
    config.add_route('project_new', '/project/new')
    config.add_route('project', '/project/{project}')
    config.add_route('project_edit', '/project/{project}/edit')
    config.add_route('project_partition', '/project/{project}/partition')
    config.add_route('project_mapnik', '/project/{project}/{z}/{x}/{y}.{format}')
    config.add_route('project_check_for_update', '/project/{project}/check_for_updates')
    config.add_route('task_xhr', '/task/{id}', xhr=True)
    config.add_route('task_done', '/task/{id}/done', xhr=True)
    config.add_route('task_lock', '/task/{id}/lock', xhr=True)
    config.add_route('task_unlock', '/task/{id}/unlock', xhr=True)
    config.add_route('task_split', '/task/{id}/split', xhr=True)
    config.add_route('task_invalidate', '/task/{id}/invalidate', xhr=True)
    config.add_route('users', '/users')
    config.add_route('user', '/user/{username}')
    config.add_route('user_admin', '/user/{id}/admin')
    config.add_route('user_messages', '/user/messages')
    config.add_route('user_prefered_editor', '/user/prefered_editor/{editor}', xhr=True)<commit_msg>Fixed mako templates incompatibilites with Pyramid 1.5a<commit_after>from pyramid.config import Configurator
from sqlalchemy import engine_from_config
from pyramid.authentication import AuthTktAuthenticationPolicy
from pyramid.authorization import ACLAuthorizationPolicy
from pyramid.session import UnencryptedCookieSessionFactoryConfig

from .models import (
    DBSession,
    Base,
    )

from .resources import (
    MapnikRendererFactory
    )

from sqlalchemy_i18n.manager import translation_manager

from .security import (
    RootFactory,
    group_membership,
    )

def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    settings['mako.directories'] = 'osmtm:templates'

    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    Base.metadata.bind = engine

    authn_policy = AuthTktAuthenticationPolicy(
            secret='super_secret',
            callback=group_membership)
    authz_policy = ACLAuthorizationPolicy()
    config = Configurator(settings=settings,
            root_factory=RootFactory,
            authentication_policy=authn_policy,
            authorization_policy=authz_policy)
    # fixes backwards incompatibilities when running Pyramid 1.5a
    # https://pypi.python.org/pypi/pyramid#features
    config.include('pyramid_mako')

    session_factory = UnencryptedCookieSessionFactoryConfig('itsasecret')
    config.set_session_factory(session_factory)

    config.add_static_view('static', 'static', cache_max_age=3600)
    config.add_route('home', '/')
    config.add_route('login', '/login')
    config.add_route('logout', '/logout')
    config.add_route('oauth_callback', '/oauth_callback')
    config.add_route('project_new', '/project/new')
    config.add_route('project', '/project/{project}')
    config.add_route('project_edit', '/project/{project}/edit')
    config.add_route('project_partition', '/project/{project}/partition')
    config.add_route('project_mapnik', '/project/{project}/{z}/{x}/{y}.{format}')
    config.add_route('project_check_for_update', '/project/{project}/check_for_updates')
    config.add_route('task_xhr', '/task/{id}', xhr=True)
    config.add_route('task_done', '/task/{id}/done', xhr=True)
    config.add_route('task_lock', '/task/{id}/lock', xhr=True)
    config.add_route('task_unlock', '/task/{id}/unlock', xhr=True)
    config.add_route('task_split', '/task/{id}/split', xhr=True)
    config.add_route('task_invalidate', '/task/{id}/invalidate', xhr=True)
    config.add_route('users', '/users')
    config.add_route('user', '/user/{username}')
    config.add_route('user_admin', '/user/{id}/admin')
    config.add_route('user_messages', '/user/messages')
    config.add_route('user_prefered_editor', '/user/prefered_editor/{editor}', xhr=True)
{'fraction_non_alphanumeric': 0.13739194408681257, 'fraction_numerical': 0.002942799337870149, 'mean_word_length': 4.706190975865687, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6768576', 'n_tokens_mistral': 1697, 'n_tokens_neox': 1658, 'n_words': 256}