summaryrefslogtreecommitdiff
path: root/repoze/bfg/interfaces.py
diff options
context:
space:
mode:
authorChris McDonough <chrism@agendaless.com>2010-08-08 07:25:28 +0000
committerChris McDonough <chrism@agendaless.com>2010-08-08 07:25:28 +0000
commitd96ff9144f98bb44254f77f56e55967c46b09774 (patch)
tree7cabc160ce28460ebffd70a5e419f1c74178bd96 /repoze/bfg/interfaces.py
parent9192964c9ccc4b0c1c2f1948af1b62012a11ef7c (diff)
downloadpyramid-d96ff9144f98bb44254f77f56e55967c46b09774.tar.gz
pyramid-d96ff9144f98bb44254f77f56e55967c46b09774.tar.bz2
pyramid-d96ff9144f98bb44254f77f56e55967c46b09774.zip
- New public interface: ``repoze.bfg.exceptions.IExceptionResponse``.
This interface is provided by all internal exception classes (such as ``repoze.bfg.exceptions.NotFound`` and ``repoze.bfg.exceptions.Forbidden``), instances of which are both exception objects and can behave as WSGI response objects. This interface is made public so that exception classes which are also valid WSGI response factories can be configured to implement them or exception instances which are also or response instances can be configured to provide them. - New API class: ``repoze.bfg.view.AppendSlashNotFoundViewFactory`` (undoes previous custom_notfound_view on request passsed to append_slash_notfound_view). - Previously, two default view functions were registered at Configurator setup (one for ``repoze.bfg.exceptions.NotFound`` named ``default_notfound_view`` and one for ``repoze.bfg.exceptions.Forbidden`` named ``default_forbidden_view``) to render internal exception responses. Those default view functions have been removed, replaced with a generic default view function which is registered at Configurator setup for the ``repoze.bfg.interfaces.IExceptionResponse`` interface that simply returns the exception instance; the ``NotFound` and ``Forbidden`` classes are now still exception factories but they are also response factories which generate instances that implement the new ``repoze.bfg.interfaces.IExceptionResponse`` interface.
Diffstat (limited to 'repoze/bfg/interfaces.py')
-rw-r--r--repoze/bfg/interfaces.py22
1 files changed, 17 insertions, 5 deletions
diff --git a/repoze/bfg/interfaces.py b/repoze/bfg/interfaces.py
index def957dad..086c93f3a 100644
--- a/repoze/bfg/interfaces.py
+++ b/repoze/bfg/interfaces.py
@@ -24,6 +24,22 @@ class IWSGIApplicationCreatedEvent(Interface):
is called."""
app = Attribute(u"Published application")
+class IResponse(Interface): # not an API
+ status = Attribute('WSGI status code of response')
+ headerlist = Attribute('List of response headers')
+ app_iter = Attribute('Iterable representing the response body')
+
+class IException(Interface): # not an API
+ """ An interface representing a generic exception """
+
+class IExceptionResponse(IException, IResponse):
+ """ An interface representing a WSGI response which is also an
+ exception object. Register an exception view using this interface
+ as a ``context`` to apply the registered view for all exception
+ types raised by :mod:`repoze.bfg` internally
+ (:class:`repoze.bfg.exceptions.NotFound` and
+ :class:`repoze.bfg.exceptions.Forbidden`)."""
+
# internal interfaces
class IRequest(Interface):
@@ -35,11 +51,6 @@ class IRouteRequest(Interface):
""" *internal only* interface used as in a utility lookup to find
route-specific interfaces. Not an API."""
-class IResponse(Interface):
- status = Attribute('WSGI status code of response')
- headerlist = Attribute('List of response headers')
- app_iter = Attribute('Iterable representing the response body')
-
class IAuthenticationPolicy(Interface):
""" An object representing a BFG authentication policy. """
def authenticated_userid(request):
@@ -271,3 +282,4 @@ class ILocaleNegotiator(Interface):
class ITranslationDirectories(Interface):
""" A list object representing all known translation directories
for an application"""
+