Coverage for slidge/core/mixins/db.py: 100%
10 statements
« prev ^ index » next coverage.py v7.6.1, created at 2024-11-07 05:11 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2024-11-07 05:11 +0000
1from contextlib import contextmanager
4class UpdateInfoMixin:
5 """
6 This mixin just adds a context manager that prevents commiting to the DB
7 on every attribute change.
8 """
10 def __init__(self, *args, **kwargs):
11 super().__init__(*args, **kwargs)
12 self._updating_info = False
14 @contextmanager
15 def updating_info(self):
16 self._updating_info = True
17 yield
18 self._updating_info = False