diff options
author | 2018-05-14 20:42:41 +0100 | |
---|---|---|
committer | 2018-05-14 20:42:41 +0100 | |
commit | b7fe5de12be5c9f02adeedba45befee751ea68be (patch) | |
tree | 740be4b7dff4a8e70616e1663375ef1940604d53 /gunicorn_config.py | |
parent | Switch from using abort to using werkzeug exception (diff) |
Migration runner and migrations (#69)
* Migration runner and migrations
* Remove demo wiki data
* [Staff] Table management pages
* Fix weird travis build omission
* Address review and comments by @Volcyy
* [Tables] Fix pagination
* Move table definitions to new file with nameduple
* Linting
* Address lemon's review comments
* Address @Volcyy's review
* Address lemon's review
* Update search placeholder
* Search by key now available
Diffstat (limited to 'gunicorn_config.py')
-rw-r--r-- | gunicorn_config.py | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/gunicorn_config.py b/gunicorn_config.py index c09bee6a..00e5ccf0 100644 --- a/gunicorn_config.py +++ b/gunicorn_config.py @@ -1,15 +1,18 @@ -import html import re +from pysite.migrations.runner import run_migrations + STRIP_REGEX = re.compile(r"<[^<]+?>") WIKI_TABLE = "wiki" -def when_ready(server=None): +def when_ready(server=None, output_func=None): """ server hook that only runs when the gunicorn master process loads """ if server: output = server.log.info + elif output_func: + output = output_func else: output = print @@ -26,16 +29,4 @@ def when_ready(server=None): tables = ", ".join([f"{table}" for table in created]) output(f"Created the following tables: {tables}") - # Init the tables that require initialization - initialized = db.init_tables() - if initialized: - tables = ", ".join([f"{table} ({count} items)" for table, count in initialized.items()]) - output(f"Initialized the following tables: {tables}") - - output("Adding plain-text version of any wiki articles that don't have one...") - - for article in db.pluck(WIKI_TABLE, "html", "text", "slug"): - if "text" not in article: - article["text"] = html.unescape(STRIP_REGEX.sub("", article["html"]).strip()) - - db.insert(WIKI_TABLE, article, conflict="update") + run_migrations(db, output=output) |