Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/hatta/error.py
blob: e3f2f7a1657cd33d3f92aa2220691f11fcf350e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/python
# -*- coding: utf-8 -*-

import werkzeug.exceptions


class WikiError(werkzeug.exceptions.HTTPException):
    """Base class for all error pages."""

    def get_body(self, environ):
        request = environ.get('werkzeug.request')
        wiki = request.wiki
        context = {
            'wiki': wiki,
            'code': self.code,
            'name': self.name,
            'description': self.get_description(environ),
            'title': self.name,
            'request': request,
            'url': request.get_url,
            'download_url': request.get_download_url,
            'config': wiki.config,
        }
        template = wiki.template_env.get_template('error.html')
        return template.stream(**context)


class BadRequest(WikiError):
    code = 400


class ForbiddenErr(WikiError):
    code = 403


class NotFoundErr(WikiError):
    code = 404


class RequestEntityTooLarge(WikiError):
    code = 413


class RequestURITooLarge(WikiError):
    code = 414


class UnsupportedMediaTypeErr(WikiError):
    code = 415


class NotImplementedErr(WikiError):
    code = 501


class ServiceUnavailableErr(WikiError):
    code = 503