abs-auth-rbac-core 0.1.1__py3-none-any.whl → 0.1.2__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.
Potentially problematic release.
This version of abs-auth-rbac-core might be problematic. Click here for more details.
- {abs_auth_rbac_core-0.1.1.dist-info → abs_auth_rbac_core-0.1.2.dist-info}/METADATA +1 -1
- {abs_auth_rbac_core-0.1.1.dist-info → abs_auth_rbac_core-0.1.2.dist-info}/RECORD +3 -4
- abs_auth_rbac_core/rbac/database.py +0 -52
- {abs_auth_rbac_core-0.1.1.dist-info → abs_auth_rbac_core-0.1.2.dist-info}/WHEEL +0 -0
|
@@ -14,12 +14,11 @@ abs_auth_rbac_core/models/seeder/permission_seeder.py,sha256=j-aUy8uLHnUWpMmw1Dq
|
|
|
14
14
|
abs_auth_rbac_core/models/user.py,sha256=t_ardJOsfBiyedPg6Z4WywLiZRTPmAGYkMealZcEqJc,833
|
|
15
15
|
abs_auth_rbac_core/models/user_role.py,sha256=20pqmtJPzlUrI9ulHGouk8XlFgrGG7I6ikctb8sMUGs,706
|
|
16
16
|
abs_auth_rbac_core/rbac/__init__.py,sha256=oYjtpmfrkEbwWCBAWuRoU1fM4fCpBxkF_lwQrelK1As,79
|
|
17
|
-
abs_auth_rbac_core/rbac/database.py,sha256=4lxs3gDIMq4pnor8oHN51UImp9Ad-6_HiIdPiLI-LGc,1475
|
|
18
17
|
abs_auth_rbac_core/rbac/decorator.py,sha256=y1TJqVQLWJeMqj7PxYqlAQZ5sOj1hZv9AvChGspl8A0,1794
|
|
19
18
|
abs_auth_rbac_core/rbac/policy.conf,sha256=wghhhKxgZH0rPhh1QFrIpq9nevJT3s7OxxvXiU3zzuI,305
|
|
20
19
|
abs_auth_rbac_core/rbac/service.py,sha256=C0LTqnyecePrLSh2bAAhO9xcwZ_UAfi4CREczgcQNWc,25206
|
|
21
20
|
abs_auth_rbac_core/util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
22
21
|
abs_auth_rbac_core/util/permission_constants.py,sha256=JFavEKkAJ5mtltttCwRTTtpRlu_mJiVPB_MwsP-bIAg,65337
|
|
23
|
-
abs_auth_rbac_core-0.1.
|
|
24
|
-
abs_auth_rbac_core-0.1.
|
|
25
|
-
abs_auth_rbac_core-0.1.
|
|
22
|
+
abs_auth_rbac_core-0.1.2.dist-info/METADATA,sha256=D6M103gi3dbDuX-cJmBHEkochPUHrc96I6z0i6RcJrI,6586
|
|
23
|
+
abs_auth_rbac_core-0.1.2.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
|
|
24
|
+
abs_auth_rbac_core-0.1.2.dist-info/RECORD,,
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
from contextlib import AbstractContextManager, contextmanager
|
|
2
|
-
from typing import Any, Generator
|
|
3
|
-
from loguru import logger
|
|
4
|
-
|
|
5
|
-
from sqlalchemy import create_engine, orm
|
|
6
|
-
from sqlalchemy.orm import Session
|
|
7
|
-
from abs_repository_core.models import BaseModel
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class Database:
|
|
11
|
-
def __init__(self, db_url: str) -> None:
|
|
12
|
-
"""
|
|
13
|
-
Initialize the database engine and session factory
|
|
14
|
-
"""
|
|
15
|
-
self._engine = create_engine(
|
|
16
|
-
db_url,
|
|
17
|
-
echo=False,
|
|
18
|
-
echo_pool=False,
|
|
19
|
-
pool_pre_ping=True,
|
|
20
|
-
pool_recycle=3600,
|
|
21
|
-
query_cache_size=0,
|
|
22
|
-
)
|
|
23
|
-
self._session_factory = orm.scoped_session(
|
|
24
|
-
orm.sessionmaker(
|
|
25
|
-
autocommit=False,
|
|
26
|
-
autoflush=False,
|
|
27
|
-
bind=self._engine,
|
|
28
|
-
),
|
|
29
|
-
)
|
|
30
|
-
|
|
31
|
-
def create_database(self) -> None:
|
|
32
|
-
"""
|
|
33
|
-
Create all the tables in the database
|
|
34
|
-
"""
|
|
35
|
-
BaseModel.metadata.create_all(self._engine)
|
|
36
|
-
|
|
37
|
-
@contextmanager
|
|
38
|
-
def session(self) -> Generator[Any, Any, AbstractContextManager[Session]]:
|
|
39
|
-
"""
|
|
40
|
-
Provides a database session for the request
|
|
41
|
-
"""
|
|
42
|
-
session: Session = self._session_factory()
|
|
43
|
-
try:
|
|
44
|
-
yield session
|
|
45
|
-
except Exception as e:
|
|
46
|
-
session.rollback()
|
|
47
|
-
import traceback
|
|
48
|
-
|
|
49
|
-
logger.error(f"Exception: {e}\n{traceback.format_exc()}")
|
|
50
|
-
raise e
|
|
51
|
-
finally:
|
|
52
|
-
session.close()
|
|
File without changes
|