Show More
@@ -18,9 +18,6 b'' | |||||
18 | # RhodeCode Enterprise Edition, including its added features, Support services, |
|
18 | # RhodeCode Enterprise Edition, including its added features, Support services, | |
19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ |
|
19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ | |
20 |
|
20 | |||
21 | """ |
|
|||
22 | Pylons middleware initialization |
|
|||
23 | """ |
|
|||
24 | import logging |
|
21 | import logging | |
25 | import traceback |
|
22 | import traceback | |
26 | import collections |
|
23 | import collections | |
@@ -266,6 +263,28 b' def error_handler(exception, request):' | |||||
266 | return response |
|
263 | return response | |
267 |
|
264 | |||
268 |
|
265 | |||
|
266 | def includeme_first(config): | |||
|
267 | # redirect automatic browser favicon.ico requests to correct place | |||
|
268 | def favicon_redirect(context, request): | |||
|
269 | return HTTPFound( | |||
|
270 | request.static_path('rhodecode:public/images/favicon.ico')) | |||
|
271 | ||||
|
272 | config.add_view(favicon_redirect, route_name='favicon') | |||
|
273 | config.add_route('favicon', '/favicon.ico') | |||
|
274 | ||||
|
275 | def robots_redirect(context, request): | |||
|
276 | return HTTPFound( | |||
|
277 | request.static_path('rhodecode:public/robots.txt')) | |||
|
278 | ||||
|
279 | config.add_view(robots_redirect, route_name='robots') | |||
|
280 | config.add_route('robots', '/robots.txt') | |||
|
281 | ||||
|
282 | config.add_static_view( | |||
|
283 | '_static/deform', 'deform:static') | |||
|
284 | config.add_static_view( | |||
|
285 | '_static/rhodecode', path='rhodecode:public', cache_max_age=3600 * 24) | |||
|
286 | ||||
|
287 | ||||
269 | def includeme(config): |
|
288 | def includeme(config): | |
270 | settings = config.registry.settings |
|
289 | settings = config.registry.settings | |
271 |
|
290 | |||
@@ -320,16 +339,17 b' def includeme(config):' | |||||
320 | config.add_subscriber(write_metadata_if_needed, ApplicationCreated) |
|
339 | config.add_subscriber(write_metadata_if_needed, ApplicationCreated) | |
321 | config.add_subscriber(write_js_routes_if_enabled, ApplicationCreated) |
|
340 | config.add_subscriber(write_js_routes_if_enabled, ApplicationCreated) | |
322 |
|
341 | |||
323 | config.add_request_method( |
|
|||
324 | 'rhodecode.lib.partial_renderer.get_partial_renderer', |
|
|||
325 | 'get_partial_renderer') |
|
|||
326 |
|
||||
327 | # events |
|
342 | # events | |
328 | # TODO(marcink): this should be done when pyramid migration is finished |
|
343 | # TODO(marcink): this should be done when pyramid migration is finished | |
329 | # config.add_subscriber( |
|
344 | # config.add_subscriber( | |
330 | # 'rhodecode.integrations.integrations_event_handler', |
|
345 | # 'rhodecode.integrations.integrations_event_handler', | |
331 | # 'rhodecode.events.RhodecodeEvent') |
|
346 | # 'rhodecode.events.RhodecodeEvent') | |
332 |
|
347 | |||
|
348 | # request custom methods | |||
|
349 | config.add_request_method( | |||
|
350 | 'rhodecode.lib.partial_renderer.get_partial_renderer', | |||
|
351 | 'get_partial_renderer') | |||
|
352 | ||||
333 | # Set the authorization policy. |
|
353 | # Set the authorization policy. | |
334 | authz_policy = ACLAuthorizationPolicy() |
|
354 | authz_policy = ACLAuthorizationPolicy() | |
335 | config.set_authorization_policy(authz_policy) |
|
355 | config.set_authorization_policy(authz_policy) | |
@@ -359,28 +379,6 b' def includeme(config):' | |||||
359 | config.add_view(error_handler, context=HTTPError) |
|
379 | config.add_view(error_handler, context=HTTPError) | |
360 |
|
380 | |||
361 |
|
381 | |||
362 | def includeme_first(config): |
|
|||
363 | # redirect automatic browser favicon.ico requests to correct place |
|
|||
364 | def favicon_redirect(context, request): |
|
|||
365 | return HTTPFound( |
|
|||
366 | request.static_path('rhodecode:public/images/favicon.ico')) |
|
|||
367 |
|
||||
368 | config.add_view(favicon_redirect, route_name='favicon') |
|
|||
369 | config.add_route('favicon', '/favicon.ico') |
|
|||
370 |
|
||||
371 | def robots_redirect(context, request): |
|
|||
372 | return HTTPFound( |
|
|||
373 | request.static_path('rhodecode:public/robots.txt')) |
|
|||
374 |
|
||||
375 | config.add_view(robots_redirect, route_name='robots') |
|
|||
376 | config.add_route('robots', '/robots.txt') |
|
|||
377 |
|
||||
378 | config.add_static_view( |
|
|||
379 | '_static/deform', 'deform:static') |
|
|||
380 | config.add_static_view( |
|
|||
381 | '_static/rhodecode', path='rhodecode:public', cache_max_age=3600 * 24) |
|
|||
382 |
|
||||
383 |
|
||||
384 | def wrap_app_in_wsgi_middlewares(pyramid_app, config): |
|
382 | def wrap_app_in_wsgi_middlewares(pyramid_app, config): | |
385 | """ |
|
383 | """ | |
386 | Apply outer WSGI middlewares around the application. |
|
384 | Apply outer WSGI middlewares around the application. |
General Comments 0
You need to be logged in to leave comments.
Login now