From f5a7ccffd5157d5d5490eb6fefe67be681ad25cb Mon Sep 17 00:00:00 2001 From: Martijn Faassen Date: Thu, 5 Jul 2007 14:35:49 +0000 Subject: [PATCH] Integrate Zope 3-based exception views. Patch by Sidnei, integration work done for Infrae. --- __init__.py | 13 +++++++++---- unauthorized.py | 6 +++++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/__init__.py b/__init__.py index cddfc8f..957bc57 100644 --- a/__init__.py +++ b/__init__.py @@ -20,17 +20,22 @@ from unauthorized import Unauthorized +from zope.interface import implements +from zope.interface.common.interfaces import IException +from zope.publisher.interfaces import INotFound +from zope.security.interfaces import IForbidden + class BadRequest(Exception): - pass + implements(IException) class InternalError(Exception): - pass + implements(IException) class NotFound(Exception): - pass + implements(INotFound) class Forbidden(Exception): - pass + implements(IForbidden) class MethodNotAllowed(Exception): pass diff --git a/unauthorized.py b/unauthorized.py index 9ac7a08..9875a85 100644 --- a/unauthorized.py +++ b/unauthorized.py @@ -15,9 +15,13 @@ """ from types import StringType +from zope.interface import implements +from zope.security.interfaces import IUnauthorized class Unauthorized(Exception): - """Some user wasn't allowed to access a resource""" + """Some user wasn't allowed to access a resource + """ + implements(IUnauthorized) def __init__(self, message=None, value=None, needed=None, name=None, **kw): """Possible signatures: