From 2876a84bef0b9b26a97d657d22de86d2b6b8a657 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Tue, 2 Nov 2010 02:53:02 -0400 Subject: - The presence of the key ``repoze.bfg.message`` in the WSGI environment when an exception occurs is now deprecated. Instead, code which relies on this environ value should use the ``exception`` attribute of the request (e.g. ``request.exception[0]``) to retrieve the message. --- CHANGES.txt | 5 +++++ TODO.txt | 4 ---- pyramid/exceptions.py | 18 ++++++++---------- pyramid/router.py | 12 ++++++------ 4 files changed, 19 insertions(+), 20 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index aee4f64de..478b9c08b 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -133,3 +133,8 @@ Backwards Incompatibilities (with BFG 1.3.X) This change was made primarily to support more flexible Mako template rendering. + +- The presence of the key ``repoze.bfg.message`` in the WSGI environment when + an exception occurs is now deprecated. Instead, code which relies on this + environ value should use the ``exception`` attribute of the request + (e.g. ``request.exception[0]``) to retrieve the message. diff --git a/TODO.txt b/TODO.txt index dfb0a1712..76af553e8 100644 --- a/TODO.txt +++ b/TODO.txt @@ -72,14 +72,10 @@ - ``handler`` ZCML directive. -- ``repoze.bfg.message`` alias. - - Try to get rid of Mako Beaker dependency. - ``docs`` directory for each paster template. -- bfg.routes.matchdict and bfg.routes.route - - repoze.bfg.auth_tkt - bfg_locale_name diff --git a/pyramid/exceptions.py b/pyramid/exceptions.py index 109247c0a..314bd76f7 100644 --- a/pyramid/exceptions.py +++ b/pyramid/exceptions.py @@ -43,11 +43,10 @@ class Forbidden(ExceptionResponse): this is a basic ``401`` page, but the forbidden view can be customized as necessary. See :ref:`changing_the_forbidden_view`. - This exception's constructor accepts a single positional argument, - which should be a string. The value of this string will be placed - into the WSGI environment by the router under the - ``repoze.bfg.message`` key, for availability to the - :term:`Forbidden View`. + This exception's constructor accepts a single positional argument, which + should be a string. The value of this string will be placed onto the + request by the router as the ``exception_message`` attribute, for + availability to the :term:`Forbidden View`. """ status = '401 Unauthorized' @@ -58,11 +57,10 @@ class NotFound(ExceptionResponse): this is a basic ``404`` page, but the Not Found view can be customized as necessary. See :ref:`changing_the_notfound_view`. - This exception's constructor accepts a single positional argument, - which should be a string. The value of this string will be placed - into the WSGI environment by the router under the - ``repoze.bfg.message`` key, for availability to the :term:`Not Found - View`. + This exception's constructor accepts a single positional argument, which + should be a string. The value of this string will be placed into the WSGI + environment by the router as the ``exception_message`` attribute, for + availability to the :term:`Not Found View`. """ status = '404 Not Found' diff --git a/pyramid/router.py b/pyramid/router.py index 038bed6d6..742337b88 100644 --- a/pyramid/router.py +++ b/pyramid/router.py @@ -83,9 +83,10 @@ class Router(object): info = self.routes_mapper(request) match, route = info['match'], info['route'] if route is not None: - # TODO: kill off bfg.routes.* environ keys - # when traverser requires request arg, and - # cant cope with environ anymore (likely 1.4+) + # TODO: kill off bfg.routes.* environ keys when + # traverser requires request arg, and cant cope + # with environ anymore (they are docs-deprecated as + # of BFG 1.3) environ['bfg.routes.route'] = route environ['bfg.routes.matchdict'] = match attrs['matchdict'] = match @@ -132,8 +133,6 @@ class Router(object): logger and logger.debug(msg) else: msg = request.path_info - # XXX repoze.bfg.message should be deprecated - environ['repoze.bfg.message'] = msg raise NotFound(msg) else: response = view_callable(context, request) @@ -150,11 +149,12 @@ class Router(object): if view_callable is None: raise - # XXX r.b.message should be deprecated try: msg = why[0] except: msg = '' + + # repoze.bfg.message docs-deprecated in Pyramid 1.0 environ['repoze.bfg.message'] = msg response = view_callable(why, request) -- cgit v1.2.3