aurweb/aurweb
Kevin Morris a5943bf2ad
[FastAPI] Refactor db modifications
For SQLAlchemy to automatically understand updates from the
external world, it must use an `autocommit=True` in its session.

This change breaks how we were using commit previously, as
`autocommit=True` causes SQLAlchemy to commit when a
SessionTransaction context hits __exit__.

So, a refactoring was required of our tests: All usage of
any `db.{create,delete}` must be called **within** a
SessionTransaction context, created via new `db.begin()`.

From this point forward, we're going to require:

```
with db.begin():
    db.create(...)
    db.delete(...)
    db.session.delete(object)
```

With this, we now get external DB modifications automatically
without reloading or restarting the FastAPI server, which we
absolutely need for production.

Signed-off-by: Kevin Morris <kevr@0cost.org>
2021-09-03 15:03:34 -07:00
..
git remove unused imports, rectify isort violations 2021-06-05 21:27:39 -07:00
models [FastAPI] Refactor db modifications 2021-09-03 15:03:34 -07:00
packages [FastAPI] Modularize homepage and add side panel 2021-08-17 19:58:32 -07:00
routers [FastAPI] Refactor db modifications 2021-09-03 15:03:34 -07:00
scripts rendercomment: move Repository init to __init__ 2021-07-20 18:48:28 -07:00
testing implement /packages/{name} as its own route 2021-07-27 20:48:40 -07:00
__init__.py Use setuptools to install Python modules 2016-09-29 22:07:06 +02:00
asgi.py [FastAPI] Basic pkgbase template 2021-07-27 20:48:40 -07:00
auth.py routers.packages: Simplify some existence checks 2021-08-09 23:42:54 -07:00
cache.py add aurweb.cache, a redis caching utility module 2021-08-17 19:58:31 -07:00
captcha.py fastapi: Jinja contextfilter renamed to pass_context 2021-06-05 20:11:17 -07:00
config.py Port homepage intro to fastapi 2021-06-27 15:17:04 +02:00
db.py [FastAPI] Refactor db modifications 2021-09-03 15:03:34 -07:00
exceptions.py git-serve: check update hook permissions 2019-11-23 11:18:16 -05:00
initdb.py add logging.config.fileConfig 2021-06-24 18:56:38 -07:00
l10n.py jinja2: add 'tn' filter, a numerical translation 2021-08-30 18:49:01 -07:00
logging.py add logging.config.fileConfig 2021-06-24 18:56:38 -07:00
redis.py aurweb.redis: Reduce logging 2021-08-17 21:59:15 -07:00
schema.py aurweb.schema: Fix off-by-one String impls of DECIMAL 2021-06-11 19:57:52 -07:00
spawn.py [php] aurweb.spawn avoid permission denied when running as user 2021-06-29 18:02:20 +01:00
templates.py Eradicate the dedupe_qs filter 2021-08-31 14:44:29 -07:00
time.py add aurweb.time module 2021-06-05 20:11:17 -07:00
util.py Eradicate the dedupe_qs filter 2021-08-31 14:44:29 -07:00