jararaca 0.3.12a9__py3-none-any.whl → 0.3.12a11__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 jararaca might be problematic. Click here for more details.

jararaca/__init__.py CHANGED
@@ -119,6 +119,11 @@ if TYPE_CHECKING:
119
119
  use_session,
120
120
  use_transaction,
121
121
  )
122
+ from .persistence.interceptors.decorators import (
123
+ set_use_persistence_session,
124
+ skip_persistence_session,
125
+ uses_persistence_session,
126
+ )
122
127
  from .persistence.utilities import (
123
128
  CriteriaBasedAttributeQueryInjector,
124
129
  CRUDOperations,
@@ -249,6 +254,9 @@ if TYPE_CHECKING:
249
254
  "use_transaction",
250
255
  "providing_session",
251
256
  "provide_session",
257
+ "uses_persistence_session",
258
+ "skip_persistence_session",
259
+ "set_use_persistence_session",
252
260
  "providing_transaction",
253
261
  "providing_new_session",
254
262
  "Post",
@@ -450,6 +458,21 @@ _dynamic_imports: "dict[str, tuple[str, str, str | None]]" = {
450
458
  "persistence.interceptors.aiosqa_interceptor",
451
459
  None,
452
460
  ),
461
+ "uses_persistence_session": (
462
+ __SPEC_PARENT__,
463
+ "persistence.interceptors.decorators",
464
+ None,
465
+ ),
466
+ "skip_persistence_session": (
467
+ __SPEC_PARENT__,
468
+ "persistence.interceptors.decorators",
469
+ None,
470
+ ),
471
+ "set_use_persistence_session": (
472
+ __SPEC_PARENT__,
473
+ "persistence.interceptors.decorators",
474
+ None,
475
+ ),
453
476
  "Post": (__SPEC_PARENT__, "presentation.decorators", None),
454
477
  "Get": (__SPEC_PARENT__, "presentation.decorators", None),
455
478
  "Patch": (__SPEC_PARENT__, "presentation.decorators", None),
@@ -12,9 +12,11 @@ from sqlalchemy.ext.asyncio import (
12
12
  from sqlalchemy.ext.asyncio.engine import AsyncEngine
13
13
 
14
14
  from jararaca.microservice import AppInterceptor, AppTransactionContext
15
- from jararaca.reflect.metadata import SetMetadata, get_metadata_value
16
-
17
- DEFAULT_CONNECTION_NAME = "default"
15
+ from jararaca.persistence.interceptors.constants import DEFAULT_CONNECTION_NAME
16
+ from jararaca.persistence.interceptors.decorators import (
17
+ INJECT_PERSISTENCE_SESSION_METADATA_TEMPLATE,
18
+ )
19
+ from jararaca.reflect.metadata import get_metadata_value
18
20
 
19
21
  ctx_default_connection_name: ContextVar[str] = ContextVar(
20
22
  "ctx_default_connection_name", default=DEFAULT_CONNECTION_NAME
@@ -129,49 +131,6 @@ class AIOSQAConfig:
129
131
  self.inject_default = inject_default
130
132
 
131
133
 
132
- INJECT_CONNECTION_METADATA = "inject_connection_metadata_{connection_name}"
133
-
134
-
135
- def set_inject_connection(
136
- inject: bool, connection_name: str = DEFAULT_CONNECTION_NAME
137
- ) -> SetMetadata:
138
- """
139
- Set whether to inject the connection metadata for the given connection name.
140
- This is useful when you want to control whether the connection metadata
141
- should be injected into the context or not.
142
- """
143
-
144
- return SetMetadata(
145
- INJECT_CONNECTION_METADATA.format(connection_name=connection_name), inject
146
- )
147
-
148
-
149
- def uses_connection(
150
- connection_name: str = DEFAULT_CONNECTION_NAME,
151
- ) -> SetMetadata:
152
- """
153
- Use connection metadata for the given connection name.
154
- This is useful when you want to inject the connection metadata into the context,
155
- for example, when you are using a specific connection for a specific operation.
156
- """
157
- return SetMetadata(
158
- INJECT_CONNECTION_METADATA.format(connection_name=connection_name), True
159
- )
160
-
161
-
162
- def dnt_uses_connection(
163
- connection_name: str = DEFAULT_CONNECTION_NAME,
164
- ) -> SetMetadata:
165
- """
166
- Do not use connection metadata for the given connection name.
167
- This is useful when you want to ensure that the connection metadata is not injected
168
- into the context, for example, when you are using a different connection for a specific operation.
169
- """
170
- return SetMetadata(
171
- INJECT_CONNECTION_METADATA.format(connection_name=connection_name), False
172
- )
173
-
174
-
175
134
  class AIOSqlAlchemySessionInterceptor(AppInterceptor):
176
135
 
177
136
  def __init__(self, config: AIOSQAConfig):
@@ -190,7 +149,7 @@ class AIOSqlAlchemySessionInterceptor(AppInterceptor):
190
149
  ) -> AsyncGenerator[None, None]:
191
150
 
192
151
  uses_connection_metadata = get_metadata_value(
193
- INJECT_CONNECTION_METADATA.format(
152
+ INJECT_PERSISTENCE_SESSION_METADATA_TEMPLATE.format(
194
153
  connection_name=self.config.connection_name
195
154
  ),
196
155
  self.config.inject_default,
@@ -0,0 +1 @@
1
+ DEFAULT_CONNECTION_NAME = "default"
@@ -0,0 +1,45 @@
1
+ from jararaca.persistence.interceptors.constants import DEFAULT_CONNECTION_NAME
2
+ from jararaca.reflect.metadata import SetMetadata
3
+
4
+ INJECT_PERSISTENCE_SESSION_METADATA_TEMPLATE = (
5
+ "inject_persistence_template_{connection_name}"
6
+ )
7
+
8
+
9
+ def set_use_persistence_session(
10
+ inject: bool, connection_name: str = DEFAULT_CONNECTION_NAME
11
+ ) -> SetMetadata:
12
+ """
13
+ Set whether to inject the connection metadata for the given connection name.
14
+ This is useful when you want to control whether the connection metadata
15
+ should be injected into the context or not.
16
+ """
17
+
18
+ return SetMetadata(
19
+ INJECT_PERSISTENCE_SESSION_METADATA_TEMPLATE.format(
20
+ connection_name=connection_name
21
+ ),
22
+ inject,
23
+ )
24
+
25
+
26
+ def uses_persistence_session(
27
+ connection_name: str = DEFAULT_CONNECTION_NAME,
28
+ ) -> SetMetadata:
29
+ """
30
+ Use connection metadata for the given connection name.
31
+ This is useful when you want to inject the connection metadata into the context,
32
+ for example, when you are using a specific connection for a specific operation.
33
+ """
34
+ return set_use_persistence_session(True, connection_name=connection_name)
35
+
36
+
37
+ def skip_persistence_session(
38
+ connection_name: str = DEFAULT_CONNECTION_NAME,
39
+ ) -> SetMetadata:
40
+ """
41
+ Decorator to skip using connection metadata for the given connection name.
42
+ This is useful when you want to ensure that the connection metadata is not injected
43
+ into the context, for example, when you are using a different connection for a specific operation.
44
+ """
45
+ return set_use_persistence_session(False, connection_name=connection_name)
@@ -6,7 +6,7 @@ from typing import Any, Awaitable, Callable, Mapping, TypeVar, Union, cast
6
6
  DECORATED = TypeVar("DECORATED", bound=Union[Callable[..., Awaitable[Any]], type])
7
7
 
8
8
 
9
- @dataclass
9
+ @dataclass(frozen=True)
10
10
  class ControllerInstanceMetadata:
11
11
  value: Any
12
12
  inherited: bool
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: jararaca
3
- Version: 0.3.12a9
3
+ Version: 0.3.12a11
4
4
  Summary: A simple and fast API framework for Python
5
5
  Home-page: https://github.com/LuscasLeo/jararaca
6
6
  Author: Lucas S
@@ -1,7 +1,7 @@
1
1
  LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
2
2
  README.md,sha256=2qMM__t_MoLKZr4IY9tXjo-Jn6LKjuHMb1qbyXpgL08,3401
3
- pyproject.toml,sha256=wOOoLM20gk9CiB8WX1sRhKlkAmGcb46L1H9f5cVz3K8,2040
4
- jararaca/__init__.py,sha256=jN3paW2ujI97485DNZTcRe_8ORwO-OQbJUG5mmSI9LI,21226
3
+ pyproject.toml,sha256=uOD1sjQvYMshstzAtrSkxvKtqKX_SheTuywTHkupokM,2041
4
+ jararaca/__init__.py,sha256=h3MkFZ9xNllb-YTB-M1WH2HnSJbkev6t1c984Nn6G1w,21887
5
5
  jararaca/__main__.py,sha256=-O3vsB5lHdqNFjUtoELDF81IYFtR-DSiiFMzRaiSsv4,67
6
6
  jararaca/broker_backend/__init__.py,sha256=GzEIuHR1xzgCJD4FE3harNjoaYzxHMHoEL0_clUaC-k,3528
7
7
  jararaca/broker_backend/mapper.py,sha256=vTsi7sWpNvlga1PWPFg0rCJ5joJ0cdzykkIc2Tuvenc,696
@@ -32,7 +32,9 @@ jararaca/observability/providers/otel.py,sha256=8N1F32W43t7c8cwmtTh6Yz9b7HyfGFSR
32
32
  jararaca/persistence/base.py,sha256=xnGUbsLNz3gO-9iJt-Sn5NY13Yc9-misP8wLwQuGGoM,1024
33
33
  jararaca/persistence/exports.py,sha256=Ghx4yoFaB4QVTb9WxrFYgmcSATXMNvrOvT8ybPNKXCA,62
34
34
  jararaca/persistence/interceptors/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
35
- jararaca/persistence/interceptors/aiosqa_interceptor.py,sha256=LYuKNHYa1CSqJGh-n9iXHT0y73anAbb_DMhyEsjP7bI,6597
35
+ jararaca/persistence/interceptors/aiosqa_interceptor.py,sha256=_qhTONCtusGIvQg3FOHVnsxWXGi77gsNi1fH0Cv6kxg,5301
36
+ jararaca/persistence/interceptors/constants.py,sha256=o8g5RxDX9dSSnM9eXYlTJalGPfWxYm6-CAA8-FooUzE,36
37
+ jararaca/persistence/interceptors/decorators.py,sha256=p37r9ux5w_bvn8xPNPhScl3fjCc2enqTR0cJYLxMsrI,1627
36
38
  jararaca/persistence/session.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
37
39
  jararaca/persistence/sort_filter.py,sha256=agggpN0YvNjUr6wJjy69NkaqxoDDW13ys9B3r85OujA,9226
38
40
  jararaca/persistence/utilities.py,sha256=imcV4Oi5kXNk6m9QF2-OsnFpcTRY4w5mBYLdEx5XTSQ,14296
@@ -51,7 +53,7 @@ jararaca/presentation/websocket/websocket_interceptor.py,sha256=JWn_G8Q2WO0-1kmN
51
53
  jararaca/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
52
54
  jararaca/reflect/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
53
55
  jararaca/reflect/controller_inspect.py,sha256=UtV4pRIOqCoK4ogBTXQE0dyopEQ5LDFhwm-1iJvrkJc,2326
54
- jararaca/reflect/metadata.py,sha256=oTi0zIjCYkeBhs12PNTLc8GmzR6qWHdl3drlmamXLJo,1897
56
+ jararaca/reflect/metadata.py,sha256=jt9G51uNE7kZg6vouw6iA7rdar0vc4r9Pyw8M-yxiss,1910
55
57
  jararaca/rpc/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
56
58
  jararaca/rpc/http/__init__.py,sha256=Xp7-d-cVj7EK1JloSUbSnGBfER5YwCfp7LCU6wCAf1c,2396
57
59
  jararaca/rpc/http/backends/__init__.py,sha256=Q1tIj1PTjB4__qTZndGMu4IjP5lbayLbQZJ4fZXcnAk,166
@@ -72,8 +74,8 @@ jararaca/tools/typescript/interface_parser.py,sha256=SsTgYUWhX79e2rvcu5A5kvs7bJ3
72
74
  jararaca/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
73
75
  jararaca/utils/rabbitmq_utils.py,sha256=ytdAFUyv-OBkaVnxezuJaJoLrmN7giZgtKeet_IsMBs,10918
74
76
  jararaca/utils/retry.py,sha256=DzPX_fXUvTqej6BQ8Mt2dvLo9nNlTBm7Kx2pFZ26P2Q,4668
75
- jararaca-0.3.12a9.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
76
- jararaca-0.3.12a9.dist-info/METADATA,sha256=HG8UYnEGp2ws6jsKRjF3l2SU_R9RuXJk6m4tRzhQeOU,4995
77
- jararaca-0.3.12a9.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
78
- jararaca-0.3.12a9.dist-info/entry_points.txt,sha256=WIh3aIvz8LwUJZIDfs4EeH3VoFyCGEk7cWJurW38q0I,45
79
- jararaca-0.3.12a9.dist-info/RECORD,,
77
+ jararaca-0.3.12a11.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
78
+ jararaca-0.3.12a11.dist-info/METADATA,sha256=kgieepWNDIL1SoFMf_fTt3zKQuHZ0gYWjZDVFeG13ow,4996
79
+ jararaca-0.3.12a11.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
80
+ jararaca-0.3.12a11.dist-info/entry_points.txt,sha256=WIh3aIvz8LwUJZIDfs4EeH3VoFyCGEk7cWJurW38q0I,45
81
+ jararaca-0.3.12a11.dist-info/RECORD,,
pyproject.toml CHANGED
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "jararaca"
3
- version = "0.3.12a9"
3
+ version = "0.3.12a11"
4
4
  description = "A simple and fast API framework for Python"
5
5
  authors = ["Lucas S <me@luscasleo.dev>"]
6
6
  readme = "README.md"