GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

ErrorController.document()   A
last analyzed

Complexity

Conditions 3

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
c 0
b 0
f 0
dl 0
loc 18
rs 9.4285
1
# -*- coding: utf-8 -*-
2
"""Error controller"""
3
from tg import request, expose
4
5
from pyjobsweb.lib.base import BaseController
6
7
__all__ = ['ErrorController']
8
9
10
class ErrorController(BaseController):
11
    """
12
    Generates error documents as and when they are required.
13
14
    The ErrorDocuments middleware forwards to ErrorController when error
15
    related status codes are returned from the application.
16
17
    This behaviour can be altered by changing the parameters to the
18
    ErrorDocuments middleware in your config/middleware.py file.
19
20
    """
21
22
    @expose('pyjobsweb.templates.error')
23
    def document(self, *args, **kwargs):
24
        """Render the error document"""
25
        resp = request.environ.get('tg.original_response')
26
        try:
27
            # tg.abort exposes the message as .detail in response
28
            message = resp.detail
29
        except:
30
            message = None
31
32
        if not message:
33
            message = ("<p>We're sorry but we weren't able to process "
34
                       " this request.</p>")
35
36
        values = dict(prefix=request.environ.get('SCRIPT_NAME', ''),
37
                      code=request.params.get('code', resp.status_int),
38
                      message=request.params.get('message', message))
39
        return values
40