aboutsummaryrefslogtreecommitdiffstats
path: root/pysite/base_route.py
diff options
context:
space:
mode:
authorGravatar Gareth Coles <[email protected]>2018-02-09 12:19:55 +0000
committerGravatar GitHub <[email protected]>2018-02-09 12:19:55 +0000
commitb38a9f56e54eb21eec37f40075399961ba82906f (patch)
tree3255dc43a11734726509a1ed79d7dfa1da02cb63 /pysite/base_route.py
parentWeird, PyCharm didn't commit all my changes last push (diff)
Move from straight app registration to Blueprints (#6)
Diffstat (limited to 'pysite/base_route.py')
-rw-r--r--pysite/base_route.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/pysite/base_route.py b/pysite/base_route.py
index 916e7fae..8274e66f 100644
--- a/pysite/base_route.py
+++ b/pysite/base_route.py
@@ -1,5 +1,5 @@
# coding=utf-8
-from flask import Flask, render_template
+from flask import Blueprint, render_template
from flask.views import MethodView
@@ -17,19 +17,19 @@ class RouteView(BaseView):
path = None # type: str
@classmethod
- def setup(cls: "RouteView", app: Flask):
+ def setup(cls: "RouteView", blueprint: Blueprint):
if not cls.path or not cls.name:
raise RuntimeError("Route views must have both `path` and `name` defined")
- app.add_url_rule(cls.path, view_func=cls.as_view(cls.name))
+ blueprint.add_url_rule(cls.path, view_func=cls.as_view(cls.name))
class ErrorView(BaseView):
error_code = None # type: int
@classmethod
- def setup(cls: "ErrorView", app: Flask):
+ def setup(cls: "ErrorView", blueprint: Blueprint):
if not cls.name or not cls.error_code:
raise RuntimeError("Error views must have both `name` and `error_code` defined")
- app._register_error_handler(None, cls.error_code, cls.as_view(cls.name))
+ blueprint.errorhandler(cls.error_code)(cls.as_view(cls.name))