diff options
author | 2018-02-15 14:31:13 +0000 | |
---|---|---|
committer | 2018-02-15 14:31:13 +0000 | |
commit | c09a23ef289cb1de7129c555f7fd1c4e2839bc84 (patch) | |
tree | 009d6c3995e12855b78daa0d83d9402c1a159206 /pysite/base_route.py | |
parent | Move API validation decorator to its own file #yxdk (diff) |
Fix up API key validation and database api location
Diffstat (limited to 'pysite/base_route.py')
-rw-r--r-- | pysite/base_route.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/pysite/base_route.py b/pysite/base_route.py index e1b9c6b2..fe8632de 100644 --- a/pysite/base_route.py +++ b/pysite/base_route.py @@ -2,6 +2,7 @@ import os import random import string +from _weakref import ref from flask import Blueprint, g, jsonify, render_template from flask.views import MethodView @@ -153,6 +154,7 @@ class DBViewMixin: if not cls.table_name: raise RuntimeError("Routes using DBViewMixin must define `table_name`") + cls._db = ref(manager.db) manager.db.create_table(cls.table_name, primary_key=cls.table_primary_key) @property @@ -161,7 +163,7 @@ class DBViewMixin: @property def db(self) -> RethinkDB: - return g.db + return self._db() class ErrorView(BaseView): |