plexus-python-pulse-common 1.1.88__py3-none-any.whl → 1.1.90__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- plexus/pulse/common/utils/apiutils.py +22 -5
- {plexus_python_pulse_common-1.1.88.dist-info → plexus_python_pulse_common-1.1.90.dist-info}/METADATA +5 -5
- {plexus_python_pulse_common-1.1.88.dist-info → plexus_python_pulse_common-1.1.90.dist-info}/RECORD +5 -5
- {plexus_python_pulse_common-1.1.88.dist-info → plexus_python_pulse_common-1.1.90.dist-info}/WHEEL +0 -0
- {plexus_python_pulse_common-1.1.88.dist-info → plexus_python_pulse_common-1.1.90.dist-info}/top_level.txt +0 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
from collections.abc import Callable, Mapping
|
|
1
2
|
from contextlib import AbstractContextManager
|
|
2
3
|
|
|
3
4
|
import sqlalchemy.orm as sa_orm
|
|
@@ -5,14 +6,21 @@ from fastapi import HTTPException
|
|
|
5
6
|
from plexus.common.utils import logger
|
|
6
7
|
|
|
7
8
|
__all__ = [
|
|
8
|
-
"
|
|
9
|
+
"database_transaction",
|
|
9
10
|
]
|
|
10
11
|
|
|
11
12
|
|
|
12
|
-
class
|
|
13
|
-
def __init__(
|
|
13
|
+
class DBTransactionManager(AbstractContextManager):
|
|
14
|
+
def __init__(
|
|
15
|
+
self,
|
|
16
|
+
db: sa_orm.Session,
|
|
17
|
+
*,
|
|
18
|
+
commit_on_exit: bool,
|
|
19
|
+
redirect: Mapping[type[Exception], Callable[[Exception], HTTPException]] | None = None,
|
|
20
|
+
):
|
|
14
21
|
self.db = db
|
|
15
22
|
self.commit_on_exit = commit_on_exit
|
|
23
|
+
self.redirect = redirect
|
|
16
24
|
|
|
17
25
|
def __enter__(self):
|
|
18
26
|
return self
|
|
@@ -39,9 +47,18 @@ class DBSessionExceptionManager(AbstractContextManager):
|
|
|
39
47
|
if isinstance(exc_value, HTTPException) or not isinstance(exc_value, Exception):
|
|
40
48
|
return
|
|
41
49
|
|
|
50
|
+
for exception_type, make_response in (self.redirect or {}).items():
|
|
51
|
+
if isinstance(exc_value, exception_type):
|
|
52
|
+
raise make_response(exc_value) from exc_value
|
|
53
|
+
|
|
42
54
|
logger.error("Database session failed", exc_info=(type(exc_value), exc_value, exc_value.__traceback__))
|
|
43
55
|
raise HTTPException(status_code=500, detail="Internal server error") from exc_value
|
|
44
56
|
|
|
45
57
|
|
|
46
|
-
def
|
|
47
|
-
|
|
58
|
+
def database_transaction(
|
|
59
|
+
db: sa_orm.Session,
|
|
60
|
+
*,
|
|
61
|
+
commit_on_exit: bool = True,
|
|
62
|
+
redirect: Mapping[type[Exception], Callable[[Exception], HTTPException]] | None = None,
|
|
63
|
+
) -> DBTransactionManager:
|
|
64
|
+
return DBTransactionManager(db, commit_on_exit=commit_on_exit, redirect=redirect)
|
{plexus_python_pulse_common-1.1.88.dist-info → plexus_python_pulse_common-1.1.90.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: plexus-python-pulse-common
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.90
|
|
4
4
|
Classifier: Programming Language :: Python :: 3
|
|
5
5
|
Classifier: Programming Language :: Python :: 3.12
|
|
6
6
|
Classifier: Programming Language :: Python :: 3.13
|
|
@@ -17,7 +17,7 @@ Requires-Dist: lxml>=6.0
|
|
|
17
17
|
Requires-Dist: markdown-it-py>=4.0
|
|
18
18
|
Requires-Dist: numpy>=2.3
|
|
19
19
|
Requires-Dist: packaging>=25.0
|
|
20
|
-
Requires-Dist: pydantic>=2.
|
|
20
|
+
Requires-Dist: pydantic>=2.11
|
|
21
21
|
Requires-Dist: pygeodesy>=24.10
|
|
22
22
|
Requires-Dist: pyparsing>=3.2
|
|
23
23
|
Requires-Dist: pyproj>=3.6
|
|
@@ -33,12 +33,12 @@ Requires-Dist: plexus-python-common[all]>=1.1
|
|
|
33
33
|
Provides-Extra: all
|
|
34
34
|
Requires-Dist: plexus-python-pulse-common[api]; extra == "all"
|
|
35
35
|
Provides-Extra: api
|
|
36
|
-
Requires-Dist: fastapi>=0.
|
|
37
|
-
Requires-Dist: sqlmodel>=0.0.
|
|
36
|
+
Requires-Dist: fastapi>=0.162.0; extra == "api"
|
|
37
|
+
Requires-Dist: sqlmodel>=0.0.48; extra == "api"
|
|
38
38
|
Provides-Extra: test
|
|
39
39
|
Requires-Dist: ddt>=1.7; extra == "test"
|
|
40
40
|
Requires-Dist: moto[s3,server]>=5.1; extra == "test"
|
|
41
41
|
Requires-Dist: pytest-cov>=5.0; extra == "test"
|
|
42
42
|
Requires-Dist: pytest-order>=1.3; extra == "test"
|
|
43
43
|
Requires-Dist: pytest-postgresql>=6.1; extra == "test"
|
|
44
|
-
Requires-Dist: pytest>=
|
|
44
|
+
Requires-Dist: pytest>=9.2; extra == "test"
|
{plexus_python_pulse_common-1.1.88.dist-info → plexus_python_pulse_common-1.1.90.dist-info}/RECORD
RENAMED
|
@@ -9,7 +9,7 @@ plexus/pulse/common/resources/tags/__init__.py,sha256=1BmOq9aIT2Fr4YTzDwTrYySDhi
|
|
|
9
9
|
plexus/pulse/common/resources/tags/unittest-1.0.0.tagset.yaml,sha256=8zWjsYp3OxGfBJSiS6-r08q61Jhulol65iV5-pvF1-M,5338
|
|
10
10
|
plexus/pulse/common/resources/tags/universal-1.0.0.tagset.yaml,sha256=PRxyS5xwWcNwUjAbYqN-SafLZVviE-QSzU-DXyXNffw,80736
|
|
11
11
|
plexus/pulse/common/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
|
-
plexus/pulse/common/utils/apiutils.py,sha256=
|
|
12
|
+
plexus/pulse/common/utils/apiutils.py,sha256=dBK4QZLfBPDofaSfjmCUB-1WInL5jGyh2bf0ij8pV5c,2073
|
|
13
13
|
plexus/pulse/common/utils/bagutils.py,sha256=JcTD-9xJAhV_BYXw-Zfa_85hkyO5wUVqTqw2eMJFgVI,13116
|
|
14
14
|
plexus/pulse/common/utils/config.py,sha256=YPtFK5QHTVsXwcFBGV0rlZad0GFtsgwysQNyKYjdzvk,2409
|
|
15
15
|
plexus/pulse/common/utils/datautils.py,sha256=OWlnyFSa6UaPbSSG3HzCJHxdiHyfHAE-FUVHaLfNZoM,9335
|
|
@@ -24,7 +24,7 @@ plexus/pulse/common/utils/sqlutils.py,sha256=D6kTBjhO5YlNRt3uFlPt6z3uH61m9ajEzPY
|
|
|
24
24
|
plexus/pulse/common/utils/strutils.py,sha256=8kl88-u89FApoaq-D2ulk5DNl9kenP6vqksvVJ0iH4s,17325
|
|
25
25
|
plexus/pulse/common/utils/tagutils.py,sha256=V8eUxtWSijX6nHSCuRX2dTJz3why3TCOzPVK5YXt28s,66944
|
|
26
26
|
plexus/pulse/common/utils/testutils.py,sha256=hKPRvoN4mg8QGQJH121l59a0uo8jN5rntGQAVYplGBw,6166
|
|
27
|
-
plexus_python_pulse_common-1.1.
|
|
28
|
-
plexus_python_pulse_common-1.1.
|
|
29
|
-
plexus_python_pulse_common-1.1.
|
|
30
|
-
plexus_python_pulse_common-1.1.
|
|
27
|
+
plexus_python_pulse_common-1.1.90.dist-info/METADATA,sha256=ylKPKryCYIHEwwd0WLHqjXxeXgixXGWq6zVyOtNsHhs,1556
|
|
28
|
+
plexus_python_pulse_common-1.1.90.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
29
|
+
plexus_python_pulse_common-1.1.90.dist-info/top_level.txt,sha256=ug_g7CVwaMQuas5UzAXbHUrQvKGCn8ezc6ZNvvRlJOE,7
|
|
30
|
+
plexus_python_pulse_common-1.1.90.dist-info/RECORD,,
|
{plexus_python_pulse_common-1.1.88.dist-info → plexus_python_pulse_common-1.1.90.dist-info}/WHEEL
RENAMED
|
File without changes
|
|
File without changes
|