##// END OF EJS Templates
config: Move appenlight wrapping from pylons to pyramid.
Martin Bornhold -
r595:a49bbde4 default
parent child Browse files
Show More
@@ -29,14 +29,13 b' from paste.gzipper import make_gzip_midd'
29 29 from pylons.wsgiapp import PylonsApp
30 30 from pyramid.authorization import ACLAuthorizationPolicy
31 31 from pyramid.config import Configurator
32 from pyramid.static import static_view
33 32 from pyramid.settings import asbool, aslist
34 33 from pyramid.wsgi import wsgiapp
35 34 from pyramid.httpexceptions import HTTPError, HTTPInternalServerError
36 from pylons.controllers.util import abort, redirect
35 from pylons.controllers.util import redirect
37 36 from pyramid.events import ApplicationCreated
38 37 import pyramid.httpexceptions as httpexceptions
39 from pyramid.renderers import render_to_response, render
38 from pyramid.renderers import render_to_response
40 39 from routes.middleware import RoutesMiddleware
41 40 import routes.util
42 41
@@ -83,19 +82,13 b' class SkippableRoutesMiddleware(RoutesMi'
83 82 environ, start_response)
84 83
85 84
86 def make_app(global_conf, full_stack=True, static_files=True, **app_conf):
85 def make_app(global_conf, static_files=True, **app_conf):
87 86 """Create a Pylons WSGI application and return it
88 87
89 88 ``global_conf``
90 89 The inherited configuration for this application. Normally from
91 90 the [DEFAULT] section of the Paste ini file.
92 91
93 ``full_stack``
94 Whether or not this application provides a full WSGI stack (by
95 default, meaning it handles its own exceptions and errors).
96 Disable full_stack when this application is "managed" by
97 another WSGI middleware.
98
99 92 ``app_conf``
100 93 The application's local configuration. Normally specified in
101 94 the [app:<name>] section of the Paste ini file (where <name>
@@ -120,12 +113,6 b' def make_app(global_conf, full_stack=Tru'
120 113 app = csrf.OriginChecker(app, expected_origin,
121 114 skip_urls=[routes.util.url_for('api')])
122 115
123
124 if asbool(full_stack):
125
126 # Appenlight monitoring and error handler
127 app, appenlight_client = wrap_in_appenlight_if_enabled(app, config)
128
129 116 # Establish the Registry for this application
130 117 app = RegistryManager(app)
131 118
@@ -176,11 +163,12 b' def make_pyramid_app(global_config, **se'
176 163
177 164 def make_not_found_view(config):
178 165 """
179 This creates the view shich should be registered as not-found-view to
166 This creates the view which should be registered as not-found-view to
180 167 pyramid. Basically it contains of the old pylons app, converted to a view.
181 168 Additionally it is wrapped by some other middlewares.
182 169 """
183 170 settings = config.registry.settings
171 vcs_server_enabled = settings['vcs.server.enable']
184 172
185 173 # Make pylons app from unprepared settings.
186 174 pylons_app = make_app(
@@ -188,17 +176,19 b' def make_not_found_view(config):'
188 176 **config.registry._pylons_compat_settings)
189 177 config.registry._pylons_compat_config = pylons_app.config
190 178
179 # Appenlight monitoring.
180 pylons_app, appenlight_client = wrap_in_appenlight_if_enabled(
181 pylons_app, settings)
182
191 183 # The VCSMiddleware shall operate like a fallback if pyramid doesn't find
192 # a view to handle the request. Therefore we wrap it around the pylons app
193 # and it will be added as not found view.
194 if settings['vcs.server.enable']:
184 # a view to handle the request. Therefore we wrap it around the pylons app.
185 if vcs_server_enabled:
195 186 pylons_app = VCSMiddleware(
196 pylons_app, settings, None, registry=config.registry)
187 pylons_app, settings, appenlight_client, registry=config.registry)
197 188
198 189 pylons_app_as_view = wsgiapp(pylons_app)
199 190
200 191 # Protect from VCS Server error related pages when server is not available
201 vcs_server_enabled = asbool(settings.get('vcs.server.enable', 'true'))
202 192 if not vcs_server_enabled:
203 193 pylons_app_as_view = DisableVCSPagesWrapper(pylons_app_as_view)
204 194
General Comments 0
You need to be logged in to leave comments. Login now