aboutsummaryrefslogtreecommitdiffstats
path: root/pysite/base_route.py
diff options
context:
space:
mode:
authorGravatar Gareth Coles <[email protected]>2018-03-29 16:28:05 +0100
committerGravatar Gareth Coles <[email protected]>2018-03-29 16:28:05 +0100
commit9e394a8ad3a76c81232812070b9a60f25e6b857a (patch)
treea7528a6c37d514d8c87ffbd7dcf84583142fafed /pysite/base_route.py
parentFix static files for staff subdomain (diff)
Fix error handler management
Diffstat (limited to 'pysite/base_route.py')
-rw-r--r--pysite/base_route.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/pysite/base_route.py b/pysite/base_route.py
index 0c1c0357..3bc04728 100644
--- a/pysite/base_route.py
+++ b/pysite/base_route.py
@@ -148,6 +148,7 @@ class ErrorView(BaseView):
"""
error_code = None # type: Union[int, Iterable]
+ register_on_app = True
@classmethod
def setup(cls: "ErrorView", manager: "pysite.route_manager.RouteManager", blueprint: Blueprint):
@@ -171,7 +172,10 @@ class ErrorView(BaseView):
if isinstance(cls.error_code, Iterable):
for code in cls.error_code:
try:
- manager.app.errorhandler(code)(cls.as_view(cls.name))
+ if cls.register_on_app:
+ manager.app.errorhandler(code)(cls.as_view(cls.name))
+ else:
+ blueprint.errorhandler(code)(cls.as_view(cls.name))
except KeyError: # This happens if we try to register a handler for a HTTP code that doesn't exist
pass
else: