def _callFUT(self, app): from pyramid.wsgi import wsgiapp return wsgiapp(app)
def includeme(config): settings = config.registry.settings if asbool(settings.get('appenlight', 'false')): config.include('appenlight_client.ext.pyramid_tween') # Includes which are required. The application would fail without them. config.include('pyramid_mako') config.include('pyramid_beaker') config.include('rhodecode.admin') config.include('rhodecode.authentication') config.include('rhodecode.login') config.include('rhodecode.tweens') config.include('rhodecode.api') config.add_route('rhodecode_support', 'https://rhodecode.com/help/', static=True) # Set the authorization policy. authz_policy = ACLAuthorizationPolicy() config.set_authorization_policy(authz_policy) # Set the default renderer for HTML templates to mako. config.add_mako_renderer('.html') # plugin information config.registry.rhodecode_plugins = {} config.add_directive('register_rhodecode_plugin', register_rhodecode_plugin) # include RhodeCode plugins includes = aslist(settings.get('rhodecode.includes', [])) for inc in includes: config.include(inc) pylons_app = make_app(config.registry._pylons_compat_global_config, **config.registry._pylons_compat_settings) config.registry._pylons_compat_config = pylons_app.config pylons_app_as_view = wsgiapp(pylons_app) # Protect from VCS Server error related pages when server is not available vcs_server_enabled = asbool(settings.get('vcs.server.enable', 'true')) if not vcs_server_enabled: pylons_app_as_view = DisableVCSPagesWrapper(pylons_app_as_view) def pylons_app_with_error_handler(context, request): """ Handle exceptions from rc pylons app: - old webob type exceptions get converted to pyramid exceptions - pyramid exceptions are passed to the error handler view """ try: response = pylons_app_as_view(context, request) if 400 <= response.status_int <= 599: # webob type error responses return error_handler(webob_to_pyramid_http_response(response), request) except HTTPError as e: # pyramid type exceptions return error_handler(e, request) except Exception: if settings.get('debugtoolbar.enabled', False): raise return error_handler(HTTPInternalServerError(), request) return response # This is the glue which allows us to migrate in chunks. By registering the # pylons based application as the "Not Found" view in Pyramid, we will # fallback to the old application each time the new one does not yet know # how to handle a request. config.add_notfound_view(pylons_app_with_error_handler) if settings.get('debugtoolbar.enabled', False): # if toolbar, then only http type exceptions get caught and rendered ExcClass = HTTPError else: # if no toolbar, then any exception gets caught and rendered ExcClass = Exception config.add_view(error_handler, context=ExcClass)