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.
Completed
Push — master ( cc823b...3d112a )
by PyJobs
9s
created

ErrorController.document()   A

Complexity

Conditions 3

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

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