summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2016-02-09 20:40:58 -0500
committerChris McDonough <chrism@plope.com>2016-02-09 20:40:58 -0500
commite40ef23c9c364249318e030e5f1393a9fff17cdd (patch)
tree3c6a1cc9b728a57592d022e79b5ec29d1539066a
parent53142852745ddd5668d11801a179b03e343554c4 (diff)
downloadpyramid-e40ef23c9c364249318e030e5f1393a9fff17cdd.tar.gz
pyramid-e40ef23c9c364249318e030e5f1393a9fff17cdd.tar.bz2
pyramid-e40ef23c9c364249318e030e5f1393a9fff17cdd.zip
use exc_info instead of exc, add better docstring, mix the mixin in
-rw-r--r--pyramid/request.py2
-rw-r--r--pyramid/view.py38
2 files changed, 37 insertions, 3 deletions
diff --git a/pyramid/request.py b/pyramid/request.py
index 45d936cef..c1c1da514 100644
--- a/pyramid/request.py
+++ b/pyramid/request.py
@@ -32,6 +32,7 @@ from pyramid.util import (
InstancePropertyHelper,
InstancePropertyMixin,
)
+from pyramid.view import ViewMethodsMixin
class TemplateContext(object):
pass
@@ -154,6 +155,7 @@ class Request(
LocalizerRequestMixin,
AuthenticationAPIMixin,
AuthorizationAPIMixin,
+ ViewMethodsMixin,
):
"""
A subclass of the :term:`WebOb` Request class. An instance of
diff --git a/pyramid/view.py b/pyramid/view.py
index cedcfaef1..b09c08ccc 100644
--- a/pyramid/view.py
+++ b/pyramid/view.py
@@ -1,4 +1,5 @@
import itertools
+import traceback
import venusian
from zope.interface import providedBy
@@ -554,21 +555,52 @@ class ViewMethodsMixin(object):
views """
def invoke_exception_view(
self,
- exc,
+ exc_info=None,
request=None,
secure=True
):
+ """ Executes an exception view related to the request it's called upon.
+ The arguments it takes are these:
+
+ ``exc_info``
+
+ If provided, should be a 3-tuple in the form provided by
+ ``traceback.exc_info()``. If not provided,
+ ``traceback.exc_info()`` will be called to obtain the current
+ interpreter exception information. Default: ``None``.
+
+ ``request``
+
+ If the request to be used is not the same one as the instance that
+ this method is called upon, it may be passed here. Default:
+ ``None``.
+
+ ``secure``
+
+ If the exception view should not be rendered if the current user
+ does not have the appropriate permission, this should be ``True``.
+ Default: ``True``.
+
+ If called with no arguments, it uses the global exception information
+ returned by ``traceback.exc_info()`` as ``exc_info``, the request
+ object that the method is a member of as the ``request``, and
+ ``secure`` is ``True``.
+
+ This method returns a :term:`response` object."""
+
if request is None:
request = self
registry = getattr(request, 'registry', None)
if registry is None:
registry = get_current_registry()
- context_iface = providedBy(exc)
+ if exc_info is None:
+ exc_info = traceback.exc_info()
+ context_iface = providedBy(exc_info[0])
view_name = getattr(request, 'view_name', '')
response = _call_view(
registry,
request,
- exc,
+ exc_info[0],
context_iface,
view_name,
view_types=None,