Changeset - cfce400b9684
[Not reviewed]
stable
0 2 0
Mads Kiilerich - 6 years ago 2020-04-24 12:42:29
mads@kiilerich.com
Grafted from: cd3f17424229
tg: clarify how ErrorController hooks into TG without using config/middleware.py
2 files changed with 2 insertions and 5 deletions:
0 comments (0 inline, 0 general)
kallithea/controllers/error.py
Show inline comments
 
@@ -32,29 +32,26 @@ from tg import config, expose, request
 
from tg import tmpl_context as c
 
from tg.i18n import ugettext as _
 

	
 
from kallithea.lib.base import BaseController
 

	
 

	
 
log = logging.getLogger(__name__)
 

	
 

	
 
class ErrorController(BaseController):
 
    """Generates error documents as and when they are required.
 

	
 
    The ErrorDocuments middleware forwards to ErrorController when error
 
    The errorpage middleware renders /error/document when error
 
    related status codes are returned from the application.
 

	
 
    This behavior can be altered by changing the parameters to the
 
    ErrorDocuments middleware in your config/middleware.py file.
 
    """
 

	
 
    def _before(self, *args, **kwargs):
 
        # disable all base actions since we don't need them here
 
        pass
 

	
 
    @expose('/errors/error_document.html')
 
    def document(self, *args, **kwargs):
 
        resp = request.environ.get('tg.original_response')
 
        c.site_name = config.get('title')
 

	
 
        log.debug('### %s ###', resp and resp.status or 'no response')
kallithea/controllers/root.py
Show inline comments
 
@@ -22,14 +22,14 @@ from kallithea.lib.base import BaseContr
 
# This is the main Kallithea entry point; TurboGears will forward all requests
 
# to an instance of 'controller.root.RootController' in the configured
 
# 'application' module (set by app_cfg.py).  Requests are forwarded to
 
# controllers based on the routing mapper that lives in this root instance.
 
# The mapper is configured using routes defined in routing.py.  This use of the
 
# 'mapper' attribute is a feature of tgext.routes, which is activated by
 
# inheriting from its RoutedController class.
 
class RootController(RoutedController, BaseController):
 

	
 
    def __init__(self):
 
        self.mapper = make_map(config)
 

	
 
        # the following assignment hooks in error handling
 
        # The URL '/error/document' (the default TG errorpage.path) should be handled by ErrorController.document
 
        self.error = ErrorController()
0 comments (0 inline, 0 general)