Mercurial > moin > 1.9
changeset 4153:75b0b7f32423
Replace makeForbidden with HTTPException variant for WSGI
author | Florian Krupicka <florian.krupicka@googlemail.com> |
---|---|
date | Mon, 09 Jun 2008 17:39:28 +0200 |
parents | ddcd459c3255 |
children | fbbc33a3d40a |
files | MoinMoin/web/contexts.py MoinMoin/web/exceptions.py |
diffstat | 2 files changed, 29 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/MoinMoin/web/contexts.py Mon Jun 09 17:01:03 2008 +0200 +++ b/MoinMoin/web/contexts.py Mon Jun 09 17:39:28 2008 +0200 @@ -11,9 +11,11 @@ import re, time, inspect from werkzeug.utils import Headers, http_date +from werkzeug.exceptions import Unauthorized, NotFound from MoinMoin.request import RequestBase from MoinMoin.web.request import Request +from MoinMoin.web.exceptions import Forbidden, SurgeProtection from MoinMoin import log logging = log.getLogger(__name__) @@ -66,6 +68,13 @@ else: return self._parent.input_stream.read(n) + def makeForbidden(self, resultcode, msg): + status = { 401: Unauthorized, + 403: Forbidden, + 404: NotFound, + 503: SurgeProtection } + raise status[resultcode](msg) + class XMLRPCContext(RequestContext): pass @@ -211,3 +220,20 @@ setattr(RequestBase, name, _logfunc(item)) del name, item, FunctionType, _logfunc + + + + + from MoinMoin.request import RequestBase + from MoinMoin.web.request import Request + + from MoinMoin import log + logging = log.getLogger(__name__) +@@ -65,6 +68,26 @@ + return self._parent.data + else: + return self._parent.input_stream.read(n) + + + class XMLRPCContext(RequestContext): + pass
--- a/MoinMoin/web/exceptions.py Mon Jun 09 17:01:03 2008 +0200 +++ b/MoinMoin/web/exceptions.py Mon Jun 09 17:39:28 2008 +0200 @@ -17,12 +17,12 @@ "<p>When you restart doing requests AFTER that, slow down or you might get locked out for a longer time!</p>" ) - def __init__(self, retry_after=3600): - ServiceUnavailable.__init__(self) + def __init__(self, description=None, retry_after=3600): + exceptions.ServiceUnavailable.__init__(self, description) self.retry_after = retry_after def get_headers(self, environ): - headers = ServiceUnavailable.get_headers(self, environ) + headers = exceptions.ServiceUnavailable.get_headers(self, environ) headers.append(('Retry-After', '%d' % self.retry_after)) return headers