error-document: make sure the error document has registered helpers,

and uses only pyramid mechanics.

- in some edge cases the renderer_globals are not called and
we cannot rely on them
- this should be a purely pyramid view not relying on any of pylons
left overs.
This commit is contained in:
Marcin Kuzminski 2017-05-15 18:29:18 +02:00
parent e4c938f836
commit b2cfc90822
3 changed files with 11 additions and 7 deletions

View file

@ -22,6 +22,10 @@ from rhodecode.config import routing_links
def includeme(config):
config.add_route(
name='home',
pattern='/')
config.add_route(
name='user_autocomplete_data',
pattern='/_users')
@ -38,7 +42,7 @@ def includeme(config):
name='goto_switcher_data',
pattern='/_goto_data')
# register our static links via redirection mechanismy
# register our static links via redirection mechanism
routing_links.connect_redirection_links(config)
# Scan module for configuration decorators.

View file

@ -222,6 +222,7 @@ def add_pylons_compat_data(registry, global_config, settings):
def error_handler(exception, request):
import rhodecode
from rhodecode.lib.utils2 import AttributeDict
from rhodecode.lib import helpers
rhodecode_title = rhodecode.CONFIG.get('rhodecode_title') or 'RhodeCode'
@ -255,9 +256,9 @@ def error_handler(exception, request):
c.causes = []
if hasattr(base_response, 'causes'):
c.causes = base_response.causes
c.messages = helpers.flash.pop_messages()
response = render_to_response(
'/errors/error_document.mako', {'c': c}, request=request,
'/errors/error_document.mako', {'c': c, 'h': helpers}, request=request,
response=base_response)
return response

View file

@ -24,11 +24,10 @@
<script type="text/javascript" src="${h.asset('js/scripts.js', ver=c.rhodecode_version_hash)}"></script>
</head>
<body>
<% messages = h.flash.pop_messages() %>
<div class="wrapper error_page">
<div class="sidebar">
<a href="${h.url('home')}"><img class="error-page-logo" src="${h.asset('images/RhodeCode_Logo_Black.png')}" alt="RhodeCode"/></a>
<a href="${h.route_path('home')}"><img class="error-page-logo" src="${h.asset('images/RhodeCode_Logo_Black.png')}" alt="RhodeCode"/></a>
</div>
<div class="main-content">
<h1>
@ -37,8 +36,8 @@
</span><br/>
${c.error_message} | <span class="error_message">${c.error_explanation}</span>
</h1>
% if messages:
% for message in messages:
% if c.messages:
% for message in c.messages:
<div class="alert alert-${message.category}">${message}</div>
% endfor
% endif