diff options
| author | Chris McDonough <chrism@agendaless.com> | 2010-04-14 02:49:19 +0000 |
|---|---|---|
| committer | Chris McDonough <chrism@agendaless.com> | 2010-04-14 02:49:19 +0000 |
| commit | ff1213e8f2aed987108ba57aed517c033491b1aa (patch) | |
| tree | f531544c3373ae7d5b51746987cb373326277a9c /repoze/bfg/tests/hybridapp | |
| parent | 2b6bc8adfa294f7133680f64df411251afb67dfc (diff) | |
| download | pyramid-ff1213e8f2aed987108ba57aed517c033491b1aa.tar.gz pyramid-ff1213e8f2aed987108ba57aed517c033491b1aa.tar.bz2 pyramid-ff1213e8f2aed987108ba57aed517c033491b1aa.zip | |
Add "exception views" work contributed primarily by Andrey Popp by merging the "phash" branch.
Diffstat (limited to 'repoze/bfg/tests/hybridapp')
| -rw-r--r-- | repoze/bfg/tests/hybridapp/configure.zcml | 56 | ||||
| -rw-r--r-- | repoze/bfg/tests/hybridapp/views.py | 22 |
2 files changed, 78 insertions, 0 deletions
diff --git a/repoze/bfg/tests/hybridapp/configure.zcml b/repoze/bfg/tests/hybridapp/configure.zcml index 56c6ea8db..a94409e26 100644 --- a/repoze/bfg/tests/hybridapp/configure.zcml +++ b/repoze/bfg/tests/hybridapp/configure.zcml @@ -58,4 +58,60 @@ use_global_views="True" /> + <route + path="error" + name="route7" + /> + + <view + route_name="route7" + view=".views.erroneous_view" + /> + + <route + path="error2" + name="route8" + /> + + <view + route_name="route8" + view=".views.erroneous_view" + /> + + <!-- we want this view to "win" for route7 as exception view --> + <view + view=".views.exception_view" + for="RuntimeError" + /> + + <!-- we want this view to "win" for route8 as exception view--> + <view + route_name="route8" + view=".views.exception2_view" + for="RuntimeError" + /> + + <route + path="error_sub" + name="route9" + /> + + <view + route_name="route9" + view=".views.erroneous_sub_view" + /> + + <!-- we want this view to "win" for route9 as exception view... --> + <view + route_name="route9" + view=".views.exception2_view" + for=".views.SuperException" + /> + + <!-- ...even if we have more context-specialized view for raised exception --> + <view + view=".views.exception_view" + for=".views.SubException" + /> + </configure> diff --git a/repoze/bfg/tests/hybridapp/views.py b/repoze/bfg/tests/hybridapp/views.py index 7f60ddbfe..135ef8290 100644 --- a/repoze/bfg/tests/hybridapp/views.py +++ b/repoze/bfg/tests/hybridapp/views.py @@ -15,3 +15,25 @@ def global2_view(request): def route2_view(request): """ """ return Response('route2') + +def exception_view(request): + """ """ + return Response('supressed') + +def exception2_view(request): + """ """ + return Response('supressed2') + +def erroneous_view(request): + """ """ + raise RuntimeError() + +def erroneous_sub_view(request): + """ """ + raise SubException() + +class SuperException(Exception): + """ """ + +class SubException(SuperException): + """ """ |
