blob: 790b05bfb58b6f90ab1d2ec1753eb97d777843cd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
from szurubooru import errors, model, rest
def verify_version(
entity: model.Base, context: rest.Context, field_name: str = "version"
) -> None:
actual_version = context.get_param_as_int(field_name)
expected_version = entity.version
if actual_version != expected_version:
raise errors.IntegrityError(
"Someone else modified this in the meantime. "
+ "Please try again."
)
def bump_version(entity: model.Base) -> None:
entity.version = entity.version + 1
|
© 2015 - 2026 Jakob L. Kreuze