graftcode-context 0.0.4__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.
- graftcode/__init__.py +3 -0
- graftcode/context/__init__.py +3 -0
- graftcode/context/request_context.py +26 -0
- graftcode_context-0.0.4.dist-info/METADATA +19 -0
- graftcode_context-0.0.4.dist-info/RECORD +7 -0
- graftcode_context-0.0.4.dist-info/WHEEL +5 -0
- graftcode_context-0.0.4.dist-info/top_level.txt +1 -0
graftcode/__init__.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from contextvars import ContextVar
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class RequestContext:
|
|
7
|
+
_current: ContextVar["RequestContext"] = ContextVar("request_context_current")
|
|
8
|
+
|
|
9
|
+
def __init__(self) -> None:
|
|
10
|
+
self.headers: dict[str, str | None] = {}
|
|
11
|
+
|
|
12
|
+
@classmethod
|
|
13
|
+
def current(cls) -> "RequestContext":
|
|
14
|
+
try:
|
|
15
|
+
return cls._current.get()
|
|
16
|
+
except LookupError:
|
|
17
|
+
instance = RequestContext()
|
|
18
|
+
cls._current.set(instance)
|
|
19
|
+
return instance
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def get_headers(self) -> dict[str, str | None]:
|
|
23
|
+
return self.headers
|
|
24
|
+
|
|
25
|
+
def set_headers(self, headers: dict[str, str | None]) -> None:
|
|
26
|
+
self.headers = dict(headers)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: graftcode-context
|
|
3
|
+
Version: 0.0.4
|
|
4
|
+
Summary: This package provides context for Graftcode invocations
|
|
5
|
+
Author-email: "GRAFTCODE S.A." <support@graftcode.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Repository, https://dev.azure.com/sdncenterspzoo/GRAFTCODE/_git/graftcode-context
|
|
8
|
+
Keywords: Graftcode
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Requires-Python: >=3.9
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
|
|
17
|
+
# graftcode-context
|
|
18
|
+
|
|
19
|
+
Request context utilities for Python.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
graftcode/__init__.py,sha256=vOPU23G4IhyirLhy0CfZhGIQknpSL6JDZJXyA037F-Y,82
|
|
2
|
+
graftcode/context/__init__.py,sha256=Jf4MAgS6KURfdTXG3jShuZUrwdcC9pPstMKclzNHKeI,74
|
|
3
|
+
graftcode/context/request_context.py,sha256=Aqp6sWLKioozDN8KF7aAq07t2_O-PeB1sg0dcc4onxs,693
|
|
4
|
+
graftcode_context-0.0.4.dist-info/METADATA,sha256=RnA2KUgcoRpXCZgVhpJ058Xpuy54vwb2_z0kknIYS3M,682
|
|
5
|
+
graftcode_context-0.0.4.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
6
|
+
graftcode_context-0.0.4.dist-info/top_level.txt,sha256=FjSDIvAPx2TGC7O_SZUJh8wofc0kX-9EdvDHMhrK1AQ,10
|
|
7
|
+
graftcode_context-0.0.4.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
graftcode
|