view MoinMoin/web/exceptions.py @ 4212:1ca179133f01

Fix tests: small fixes after merge
author Florian Krupicka <florian.krupicka@googlemail.com>
date Wed, 09 Jul 2008 21:53:52 +0200
parents 75b0b7f32423
children dca46d0c55f6
line wrap: on
line source
# -*- coding: iso-8859-1 -*-
"""
    MoinMoin - HTTP exceptions

    @copyright: 2008-2008 MoinMoin:FlorianKrupicka
    @license: GNU GPL, see COPYING for details.
"""

from werkzeug import exceptions

class SurgeProtection(exceptions.ServiceUnavailable):
    name = 'Surge protection'
    description = (
        "<strong>Warning:</strong>"
        "<p>You triggered the wiki's surge protection by doing too many requests in a short time.</p>"
        "<p>Please make a short break reading the stuff you already got.</p>"
        "<p>When you restart doing requests AFTER that, slow down or you might get locked out for a longer time!</p>"
    )

    def __init__(self, description=None, retry_after=3600):
        exceptions.ServiceUnavailable.__init__(self, description)
        self.retry_after = retry_after

    def get_headers(self, environ):
        headers = exceptions.ServiceUnavailable.get_headers(self, environ)
        headers.append(('Retry-After', '%d' % self.retry_after))
        return headers

class Forbidden(exceptions.Forbidden):
    description = "<p>You are not allowed to access this!</p>"

class PageNotFound(exceptions.NotFound):
    pass