diff options
| author | Tom Harley | 2021-08-01 14:27:21 +0000 |
|---|---|---|
| committer | Tom Harley | 2021-08-02 14:41:06 +0000 |
| commit | bafe42275e65b98951dd3335342e38d7bf1b1db5 (patch) | |
| tree | 69af3fd0d1ff77baea81a3396a45c7287afdecc0 /sw/db.py | |
| parent | Support dev environment via nix-shell (diff) | |
| download | swap-bafe42275e65b98951dd3335342e38d7bf1b1db5.tar.gz swap-bafe42275e65b98951dd3335342e38d7bf1b1db5.zip | |
Utilise jinja inheritance to streamline in/outbox
untestedUsing jinja’s templating extensions, we can recreate the activitypub inheritance hierarchy without using clunky python OO.
Extending from multiple template files in sequence might cause unnecesary IO to slow response times; if this ever becomes an issue, it should be possible to pre-process some of the templating since a lot of it will be based on constant expressions (such as @context and type).
I think some formatting fixes leaked into this commit; oops! I’m leaving this note here in the hopes that if I ever want to clean this up, I can locate this commit easier.
Diffstat (limited to 'sw/db.py')
| -rw-r--r-- | sw/db.py | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -1,20 +1,27 @@ import sqlite3 +import logging + +from collections import defaultdict import click -from flask import current_app, g + +from flask import current_app, g, url_for from flask.cli import with_appcontext from werkzeug.security import generate_password_hash from sw.time import now + def get_db(): if "db" not in g: g.db = sqlite3.connect( - current_app.config["DATABASE"], detect_types=sqlite3.PARSE_DECLTYPES, + current_app.config["DATABASE"], + detect_types=sqlite3.PARSE_DECLTYPES, ) g.db.row_factory = sqlite3.Row + g.db.set_trace_callback(logging.debug) return g.db |
