maintenance.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:idealoom 作者: conversence 项目源码 文件源码
def main(global_config, **settings):
    """ Return a Pyramid WSGI application. """
    settings['config_uri'] = global_config['__file__']

    config = Configurator(registry=getGlobalSiteManager())
    config.setup_registry(settings=settings)
    config.add_translation_dirs('assembl:locale/')
    def my_locale_negotiator(request):
        locale = default_locale_negotiator(request)
        available = settings['available_languages'].split()
        locale = locale if locale in available else None
        if not locale:
            locale = request.accept_language.best_match(
                available, settings.get('pyramid.default_locale_name', 'en'))
        request._LOCALE_ = locale
        return locale

    config.set_locale_negotiator(my_locale_negotiator)

    config.add_static_view('static', 'static', cache_max_age=3600)
    config.add_static_view('widget', 'widget', cache_max_age=3600)

    config.add_view(maintenance_message)
    config.add_notfound_view(maintenance_message)
    return config.make_wsgi_app()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号