aboutsummaryrefslogtreecommitdiffstats
path: root/pysite/mixins.py
diff options
context:
space:
mode:
authorGravatar Gareth Coles <[email protected]>2018-04-07 10:10:47 +0100
committerGravatar Gareth Coles <[email protected]>2018-04-07 10:10:47 +0100
commit2db3ce6c2e91b81a64916eba47ae34f4d9182702 (patch)
tree26e22969e56caae7d18d03be3606bb9f3fbdce4a /pysite/mixins.py
parentFlake8 (diff)
Don't create tables on route load by default.
* If "FLASK_DEBUG" is in your env vars, tables will be created on route load * If you run a query against a table not declared in database.py, a warning is emitted
Diffstat (limited to 'pysite/mixins.py')
-rw-r--r--pysite/mixins.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/pysite/mixins.py b/pysite/mixins.py
index a2730ae4..c57ca85f 100644
--- a/pysite/mixins.py
+++ b/pysite/mixins.py
@@ -1,4 +1,5 @@
# coding=utf-8
+import os
from weakref import ref
from flask import Blueprint
@@ -51,7 +52,9 @@ class DBMixin:
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)
+
+ if "FLASK_DEBUG" in os.environ:
+ manager.db.create_table(cls.table_name, primary_key=cls.table_primary_key)
@property
def table(self) -> Table: