aboutsummaryrefslogtreecommitdiffstats
path: root/pysite/base_route.py
diff options
context:
space:
mode:
authorGravatar Gareth Coles <[email protected]>2018-02-06 11:47:19 +0000
committerGravatar Gareth Coles <[email protected]>2018-02-06 11:47:19 +0000
commit5c6bf7d2abee96e6baf6c2e851db503925fcc72a (patch)
treef9230655306c69e7578a344c3b12b162c6c79ed9 /pysite/base_route.py
parentRevert "Mart's Missing Files 2: Electric Boogaloo" (diff)
Template rendering
Diffstat (limited to 'pysite/base_route.py')
-rw-r--r--pysite/base_route.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/pysite/base_route.py b/pysite/base_route.py
index 17e9aee3..16bf0984 100644
--- a/pysite/base_route.py
+++ b/pysite/base_route.py
@@ -1,23 +1,29 @@
# coding=utf-8
-from flask import Flask
+from flask import Flask, render_template
from flask.views import MethodView
__author__ = "Gareth Coles"
class BaseView(MethodView):
+ def render(self, *template_names, **context):
+ # thin wrapper here in case it needs to be modified later
+ return render_template(template_names, **context)
+
+
+class RouteView(BaseView):
path = None #: str
name = None #: str
@classmethod
- def setup(cls: "BaseView", app: Flask):
+ def setup(cls: "RouteView", app: Flask):
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))
-class ErrorView(MethodView):
+class ErrorView(BaseView):
name = None #: str
error_code = None #: int