<commit_before>from fedoracommunity.config.app_cfg import base_config
from fedoracommunity.config.environment import load_environment
from moksha.middleware import (MokshaMiddleware, MokshaConnectorMiddleware,
                              MokshaExtensionPointMiddleware)

make_base_app = base_config.setup_tg_wsgi_app(load_environment)

def make_app(global_conf, full_stack=True, **app_conf):
    app = make_base_app(global_conf, wrap_app=MokshaMiddleware,
                        full_stack=True,
                        **app_conf)

    app = MokshaConnectorMiddleware(app)
    app = MokshaExtensionPointMiddleware(app)

    if base_config.squeeze:
        from repoze.squeeze.processor import ResourceSqueezingMiddleware
        app = ResourceSqueezingMiddleware(
                app,
                cache_dir='public/cache',
                url_prefix='/cache/',
                )

    if base_config.profile:
        from repoze.profile.profiler import AccumulatingProfileMiddleware
        app = AccumulatingProfileMiddleware(
                app,
                log_filename='profile.log',
                discard_first_request=True,
                flush_at_shutdown=True,
                path='/__profile__'
                )

    return app<commit_msg>fix how we load middleware so that we run inside of tg2<commit_after>from fedoracommunity.config.app_cfg import base_config
from fedoracommunity.config.environment import load_environment
from moksha.middleware import (MokshaMiddleware, MokshaConnectorMiddleware,
                              MokshaExtensionPointMiddleware)

from paste.cascade import Cascade

make_base_app = base_config.setup_tg_wsgi_app(load_environment)

def fc_middleware_wrapper(app):
    app = MokshaMiddleware(app)
    app = MokshaConnectorMiddleware(app)
    app = MokshaExtensionPointMiddleware(app)

    return app

def make_app(global_conf, full_stack=True, **app_conf):
    app = make_base_app(global_conf, wrap_app=fc_middleware_wrapper,
                        full_stack=True,
                        **app_conf)

    if base_config.squeeze:
        from repoze.squeeze.processor import ResourceSqueezingMiddleware
        app = ResourceSqueezingMiddleware(
                app,
                cache_dir='public/cache',
                url_prefix='/cache/',
                )

    if base_config.profile:
        from repoze.profile.profiler import AccumulatingProfileMiddleware
        app = AccumulatingProfileMiddleware(
                app,
                log_filename='profile.log',
                discard_first_request=True,
                flush_at_shutdown=True,
                path='/__profile__'
                )

    return app
{'fraction_non_alphanumeric': 0.062035661218424965, 'fraction_numerical': 0.0003714710252600297, 'mean_word_length': 2.400252525252525, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '2631398', 'n_tokens_mistral': 757, 'n_tokens_neox': 748, 'n_words': 130}