示例#1
0
文件: app.py 项目: wtakase/indico
def handle_exception(exception):
    Logger.get('wsgi').exception(exception.message or 'WSGI Exception')
    if current_app.debug:
        raise
    return render_error(_("An unexpected error occurred."),
                        str(exception),
                        standalone=True), 500
示例#2
0
文件: base.py 项目: wtakase/indico
 def _processForbidden(self, e):
     if session.user is None and not request.is_xhr and not e.response and request.blueprint != 'auth':
         return redirect_to_login(
             reason=_("Please log in to access this page."))
     message = _("Access Denied")
     explanation = get_error_description(e)
     return render_error(message, explanation)
示例#3
0
文件: base.py 项目: nyimbi/indico
 def _processNotFoundError(self, e):
     if isinstance(e, NotFound):
         message = _("Page not found")  # that's a bit nicer than "404: Not Found"
         explanation = get_error_description(e)
     else:
         message = e.getMessage()
         explanation = e.getExplanation()
     return render_error(message, explanation)
示例#4
0
def handle_404(exception):
    try:
        if re.search(r'\.py(?:/\S+)?$', request.path):
            # While not dangerous per se, we never serve *.py files as static
            raise NotFound
        try:
            return send_from_directory(current_app.config['INDICO_HTDOCS'], request.path[1:], conditional=True)
        except (UnicodeEncodeError, BadRequest):
            raise NotFound
    except NotFound:
        if exception.description == NotFound.description:
            # The default reason is too long and not localized
            description = _("The page you are looking for doesn't exist.")
        else:
            description = exception.description
        return render_error(_("Page not found"), description), 404
示例#5
0
文件: app.py 项目: fph/indico
def handle_404(exception):
    try:
        if re.search(r'\.py(?:/\S+)?$', request.path):
            # While not dangerous per se, we never serve *.py files as static
            raise NotFound
        try:
            return send_from_directory(current_app.config['INDICO_HTDOCS'], request.path[1:], conditional=True)
        except UnicodeEncodeError:
            raise NotFound
    except NotFound:
        if exception.description == NotFound.description:
            # The default reason is too long and not localized
            description = _("The page you are looking for doesn't exist.")
        else:
            description = exception.description
        return render_error(_("Page not found"), description), 404
示例#6
0
文件: app.py 项目: fph/indico
def handle_exception(exception):
    Logger.get('wsgi').exception(exception.message or 'WSGI Exception')
    if current_app.debug:
        raise
    return render_error(_("An unexpected error occurred."), str(exception), standalone=True), 500
示例#7
0
文件: base.py 项目: wtakase/indico
 def _processBadData(self, e):
     message = _("Invalid or expired token")
     return render_error(message, e.message)
示例#8
0
文件: base.py 项目: wtakase/indico
 def _processUnauthorized(self, e):
     message = _("Unauthorized")
     return render_error(message, e.description)
示例#9
0
文件: base.py 项目: wtakase/indico
 def _processBadRequest(self, e):
     message = _("Bad Request")
     return render_error(message, e.description)
示例#10
0
 def _processBadData(self, e):
     message = _("Invalid or expired token")
     return render_error(message, e.message)
示例#11
0
 def _processUnauthorized(self, e):
     message = _("Unauthorized")
     return render_error(message, e.description)
示例#12
0
 def _processBadRequest(self, e):
     message = _("Bad Request")
     return render_error(message, e.description)
示例#13
0
 def _processForbidden(self, e):
     if session.user is None and not request.is_xhr and not e.response and request.blueprint != 'auth':
         return redirect_to_login(reason=_("Please log in to access this page."))
     message = _("Access Denied")
     explanation = get_error_description(e)
     return render_error(message, explanation)