swarmauri_middleware_session 0.8.0.dev4__tar.gz → 0.8.0.dev34__tar.gz

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.
@@ -0,0 +1,139 @@
1
+ Metadata-Version: 2.4
2
+ Name: swarmauri_middleware_session
3
+ Version: 0.8.0.dev34
4
+ Summary: Session middleware for maintaining session state across requests.
5
+ License-Expression: Apache-2.0
6
+ License-File: LICENSE
7
+ Keywords: swarmauri,sdk,standards,middleware,session
8
+ Author: Jacob Stewart
9
+ Author-email: jacob@swarmauri.com
10
+ Requires-Python: >=3.10,<3.13
11
+ Classifier: License :: OSI Approved :: Apache Software License
12
+ Classifier: Natural Language :: English
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Development Status :: 3 - Alpha
18
+ Classifier: Programming Language :: Python
19
+ Classifier: Programming Language :: Python :: 3
20
+ Classifier: Programming Language :: Python :: 3 :: Only
21
+ Requires-Dist: fastapi
22
+ Requires-Dist: swarmauri_base
23
+ Requires-Dist: swarmauri_core
24
+ Requires-Dist: swarmauri_standard
25
+ Description-Content-Type: text/markdown
26
+
27
+ ![Swarmauri Logo](https://github.com/swarmauri/swarmauri-sdk/blob/3d4d1cfa949399d7019ae9d8f296afba773dfb7f/assets/swarmauri.brand.theme.svg)
28
+
29
+ <p align="center">
30
+ <a href="https://pypi.org/project/swarmauri_middleware_session/">
31
+ <img src="https://img.shields.io/pypi/dm/swarmauri_middleware_session" alt="PyPI - Downloads"/>
32
+ </a>
33
+ <a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_middleware_session/">
34
+ <img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_middleware_session.svg"/>
35
+ </a>
36
+ <a href="https://pypi.org/project/swarmauri_middleware_session/">
37
+ <img src="https://img.shields.io/pypi/pyversions/swarmauri_middleware_session" alt="PyPI - Python Version"/>
38
+ </a>
39
+ <a href="https://pypi.org/project/swarmauri_middleware_session/">
40
+ <img src="https://img.shields.io/pypi/l/swarmauri_middleware_session" alt="PyPI - License"/>
41
+ </a>
42
+ <a href="https://pypi.org/project/swarmauri_middleware_session/">
43
+ <img src="https://img.shields.io/pypi/v/swarmauri_middleware_session?label=swarmauri_middleware_session&color=green" alt="PyPI - swarmauri_middleware_session"/>
44
+ </a>
45
+ </p>
46
+
47
+ ---
48
+
49
+ # Swarmauri Middleware Session
50
+
51
+ Session middleware for FastAPI and Starlette style applications that keeps a
52
+ lightweight, in-memory session store synchronized with every request and
53
+ response.
54
+
55
+ ## Overview
56
+
57
+ - Accepts an incoming session identifier from the `X-Session-ID` request header
58
+ (customisable through `session_header`).
59
+ - Falls back to generating a new UUID session identifier and persists it on the
60
+ response when none is supplied.
61
+ - Stores per-session data in `session_storage`, allowing subsequent requests to
62
+ reuse state keyed by the same identifier.
63
+ - Writes the active session id to `request.state.session_id` and mirrors it in
64
+ the `session_id` response cookie (customisable through `session_cookie`).
65
+ - Uses a configurable `max_age` to control the lifetime of the emitted cookie.
66
+
67
+ ## Installation
68
+
69
+ Install from PyPI using the toolchain that fits your workflow.
70
+
71
+ ### pip
72
+
73
+ ```bash
74
+ pip install swarmauri_middleware_session
75
+ ```
76
+
77
+ ### Poetry
78
+
79
+ ```bash
80
+ poetry add swarmauri_middleware_session
81
+ ```
82
+
83
+ ### uv
84
+
85
+ ```bash
86
+ uv venv
87
+ source .venv/bin/activate
88
+ uv pip install swarmauri_middleware_session
89
+ ```
90
+
91
+ ## Example
92
+
93
+ ```python
94
+ from fastapi import FastAPI, Request
95
+ from fastapi.responses import JSONResponse
96
+ from fastapi.testclient import TestClient
97
+
98
+ from swarmauri_middleware_session import SessionMiddleware
99
+
100
+
101
+ app = FastAPI()
102
+ session_middleware = SessionMiddleware()
103
+
104
+
105
+ @app.middleware("http")
106
+ async def attach_session(request: Request, call_next):
107
+ return await session_middleware.dispatch(request, call_next)
108
+
109
+
110
+ @app.get("/greet")
111
+ async def greet(request: Request):
112
+ session_id = request.state.session_id
113
+ session_data = session_middleware.session_storage.setdefault(session_id, {})
114
+ session_data["visits"] = session_data.get("visits", 0) + 1
115
+ return JSONResponse({"session_id": session_id, "visits": session_data["visits"]})
116
+
117
+
118
+ client = TestClient(app)
119
+
120
+ first_response = client.get("/greet")
121
+ first_data = first_response.json()
122
+
123
+ second_response = client.get(
124
+ "/greet", headers={"X-Session-ID": first_response.headers["X-Session-ID"]}
125
+ )
126
+ second_data = second_response.json()
127
+
128
+ print(first_data)
129
+ print(second_data)
130
+ ```
131
+
132
+ Running the example prints the initial visit count followed by an incremented
133
+ visit count for the same session, demonstrating how the middleware keeps track
134
+ of state across requests.
135
+
136
+ ## Want to help?
137
+
138
+ If you want to contribute to swarmauri-sdk, read up on our [guidelines for contributing](https://github.com/swarmauri/swarmauri-sdk/blob/master/contributing.md) that will help you get started.
139
+
@@ -0,0 +1,112 @@
1
+ ![Swarmauri Logo](https://github.com/swarmauri/swarmauri-sdk/blob/3d4d1cfa949399d7019ae9d8f296afba773dfb7f/assets/swarmauri.brand.theme.svg)
2
+
3
+ <p align="center">
4
+ <a href="https://pypi.org/project/swarmauri_middleware_session/">
5
+ <img src="https://img.shields.io/pypi/dm/swarmauri_middleware_session" alt="PyPI - Downloads"/>
6
+ </a>
7
+ <a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_middleware_session/">
8
+ <img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_middleware_session.svg"/>
9
+ </a>
10
+ <a href="https://pypi.org/project/swarmauri_middleware_session/">
11
+ <img src="https://img.shields.io/pypi/pyversions/swarmauri_middleware_session" alt="PyPI - Python Version"/>
12
+ </a>
13
+ <a href="https://pypi.org/project/swarmauri_middleware_session/">
14
+ <img src="https://img.shields.io/pypi/l/swarmauri_middleware_session" alt="PyPI - License"/>
15
+ </a>
16
+ <a href="https://pypi.org/project/swarmauri_middleware_session/">
17
+ <img src="https://img.shields.io/pypi/v/swarmauri_middleware_session?label=swarmauri_middleware_session&color=green" alt="PyPI - swarmauri_middleware_session"/>
18
+ </a>
19
+ </p>
20
+
21
+ ---
22
+
23
+ # Swarmauri Middleware Session
24
+
25
+ Session middleware for FastAPI and Starlette style applications that keeps a
26
+ lightweight, in-memory session store synchronized with every request and
27
+ response.
28
+
29
+ ## Overview
30
+
31
+ - Accepts an incoming session identifier from the `X-Session-ID` request header
32
+ (customisable through `session_header`).
33
+ - Falls back to generating a new UUID session identifier and persists it on the
34
+ response when none is supplied.
35
+ - Stores per-session data in `session_storage`, allowing subsequent requests to
36
+ reuse state keyed by the same identifier.
37
+ - Writes the active session id to `request.state.session_id` and mirrors it in
38
+ the `session_id` response cookie (customisable through `session_cookie`).
39
+ - Uses a configurable `max_age` to control the lifetime of the emitted cookie.
40
+
41
+ ## Installation
42
+
43
+ Install from PyPI using the toolchain that fits your workflow.
44
+
45
+ ### pip
46
+
47
+ ```bash
48
+ pip install swarmauri_middleware_session
49
+ ```
50
+
51
+ ### Poetry
52
+
53
+ ```bash
54
+ poetry add swarmauri_middleware_session
55
+ ```
56
+
57
+ ### uv
58
+
59
+ ```bash
60
+ uv venv
61
+ source .venv/bin/activate
62
+ uv pip install swarmauri_middleware_session
63
+ ```
64
+
65
+ ## Example
66
+
67
+ ```python
68
+ from fastapi import FastAPI, Request
69
+ from fastapi.responses import JSONResponse
70
+ from fastapi.testclient import TestClient
71
+
72
+ from swarmauri_middleware_session import SessionMiddleware
73
+
74
+
75
+ app = FastAPI()
76
+ session_middleware = SessionMiddleware()
77
+
78
+
79
+ @app.middleware("http")
80
+ async def attach_session(request: Request, call_next):
81
+ return await session_middleware.dispatch(request, call_next)
82
+
83
+
84
+ @app.get("/greet")
85
+ async def greet(request: Request):
86
+ session_id = request.state.session_id
87
+ session_data = session_middleware.session_storage.setdefault(session_id, {})
88
+ session_data["visits"] = session_data.get("visits", 0) + 1
89
+ return JSONResponse({"session_id": session_id, "visits": session_data["visits"]})
90
+
91
+
92
+ client = TestClient(app)
93
+
94
+ first_response = client.get("/greet")
95
+ first_data = first_response.json()
96
+
97
+ second_response = client.get(
98
+ "/greet", headers={"X-Session-ID": first_response.headers["X-Session-ID"]}
99
+ )
100
+ second_data = second_response.json()
101
+
102
+ print(first_data)
103
+ print(second_data)
104
+ ```
105
+
106
+ Running the example prints the initial visit count followed by an incremented
107
+ visit count for the same session, demonstrating how the middleware keeps track
108
+ of state across requests.
109
+
110
+ ## Want to help?
111
+
112
+ If you want to contribute to swarmauri-sdk, read up on our [guidelines for contributing](https://github.com/swarmauri/swarmauri-sdk/blob/master/contributing.md) that will help you get started.
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "swarmauri_middleware_session"
3
- version = "0.8.0.dev4"
3
+ version = "0.8.0.dev34"
4
4
  description = "Session middleware for maintaining session state across requests."
5
5
  license = "Apache-2.0"
6
6
  readme = "README.md"
@@ -13,7 +13,10 @@ classifiers = [
13
13
  "Programming Language :: Python :: 3.11",
14
14
  "Programming Language :: Python :: 3.12",
15
15
  "Programming Language :: Python :: 3.13",
16
- "Development Status :: 3 - Alpha"
16
+ "Development Status :: 3 - Alpha",
17
+ "Programming Language :: Python",
18
+ "Programming Language :: Python :: 3",
19
+ "Programming Language :: Python :: 3 :: Only"
17
20
  ]
18
21
  authors = [{ name = "Jacob Stewart", email = "jacob@swarmauri.com" }]
19
22
  dependencies = [
@@ -22,6 +25,13 @@ dependencies = [
22
25
  "swarmauri_base",
23
26
  "swarmauri_standard",
24
27
  ]
28
+ keywords = [
29
+ 'swarmauri',
30
+ 'sdk',
31
+ 'standards',
32
+ 'middleware',
33
+ 'session',
34
+ ]
25
35
 
26
36
  [tool.uv.sources]
27
37
  swarmauri_core = { workspace = true }
@@ -40,6 +50,7 @@ markers = [
40
50
  "xfail: Expected failures",
41
51
  "acceptance: Acceptance tests",
42
52
  "perf: Performance tests that measure execution time and resource usage",
53
+ "example: Documentation examples",
43
54
  ]
44
55
  timeout = 300
45
56
  log_cli = true
@@ -1,57 +0,0 @@
1
- Metadata-Version: 2.3
2
- Name: swarmauri_middleware_session
3
- Version: 0.8.0.dev4
4
- Summary: Session middleware for maintaining session state across requests.
5
- License: Apache-2.0
6
- Author: Jacob Stewart
7
- Author-email: jacob@swarmauri.com
8
- Requires-Python: >=3.10,<3.13
9
- Classifier: License :: OSI Approved :: Apache Software License
10
- Classifier: Natural Language :: English
11
- Classifier: Programming Language :: Python :: 3.10
12
- Classifier: Programming Language :: Python :: 3.11
13
- Classifier: Programming Language :: Python :: 3.12
14
- Classifier: Programming Language :: Python :: 3.13
15
- Classifier: Development Status :: 3 - Alpha
16
- Requires-Dist: fastapi
17
- Requires-Dist: swarmauri_base
18
- Requires-Dist: swarmauri_core
19
- Requires-Dist: swarmauri_standard
20
- Description-Content-Type: text/markdown
21
-
22
- ![Swamauri Logo](https://res.cloudinary.com/dbjmpekvl/image/upload/v1730099724/Swarmauri-logo-lockup-2048x757_hww01w.png)
23
-
24
- <p align="center">
25
- <a href="https://pypi.org/project/swarmauri_middleware_session/">
26
- <img src="https://img.shields.io/pypi/dm/swarmauri_middleware_session" alt="PyPI - Downloads"/>
27
- </a>
28
- <a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_middleware_session/">
29
- <img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_middleware_session.svg"/>
30
- </a>
31
- <a href="https://pypi.org/project/swarmauri_middleware_session/">
32
- <img src="https://img.shields.io/pypi/pyversions/swarmauri_middleware_session" alt="PyPI - Python Version"/>
33
- </a>
34
- <a href="https://pypi.org/project/swarmauri_middleware_session/">
35
- <img src="https://img.shields.io/pypi/l/swarmauri_middleware_session" alt="PyPI - License"/>
36
- </a>
37
- <a href="https://pypi.org/project/swarmauri_middleware_session/">
38
- <img src="https://img.shields.io/pypi/v/swarmauri_middleware_session?label=swarmauri_middleware_session&color=green" alt="PyPI - swarmauri_middleware_session"/>
39
- </a>
40
- </p>
41
-
42
- ---
43
-
44
- # Swarmauri Middleware Session
45
-
46
- Session middleware for maintaining session state across requests.
47
-
48
- ## Installation
49
-
50
- ```bash
51
- pip install swarmauri_middleware_session
52
- ```
53
-
54
- ## Want to help?
55
-
56
- If you want to contribute to swarmauri-sdk, read up on our [guidelines for contributing](https://github.com/swarmauri/swarmauri-sdk/blob/master/contributing.md) that will help you get started.
57
-
@@ -1,35 +0,0 @@
1
- ![Swamauri Logo](https://res.cloudinary.com/dbjmpekvl/image/upload/v1730099724/Swarmauri-logo-lockup-2048x757_hww01w.png)
2
-
3
- <p align="center">
4
- <a href="https://pypi.org/project/swarmauri_middleware_session/">
5
- <img src="https://img.shields.io/pypi/dm/swarmauri_middleware_session" alt="PyPI - Downloads"/>
6
- </a>
7
- <a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_middleware_session/">
8
- <img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_middleware_session.svg"/>
9
- </a>
10
- <a href="https://pypi.org/project/swarmauri_middleware_session/">
11
- <img src="https://img.shields.io/pypi/pyversions/swarmauri_middleware_session" alt="PyPI - Python Version"/>
12
- </a>
13
- <a href="https://pypi.org/project/swarmauri_middleware_session/">
14
- <img src="https://img.shields.io/pypi/l/swarmauri_middleware_session" alt="PyPI - License"/>
15
- </a>
16
- <a href="https://pypi.org/project/swarmauri_middleware_session/">
17
- <img src="https://img.shields.io/pypi/v/swarmauri_middleware_session?label=swarmauri_middleware_session&color=green" alt="PyPI - swarmauri_middleware_session"/>
18
- </a>
19
- </p>
20
-
21
- ---
22
-
23
- # Swarmauri Middleware Session
24
-
25
- Session middleware for maintaining session state across requests.
26
-
27
- ## Installation
28
-
29
- ```bash
30
- pip install swarmauri_middleware_session
31
- ```
32
-
33
- ## Want to help?
34
-
35
- If you want to contribute to swarmauri-sdk, read up on our [guidelines for contributing](https://github.com/swarmauri/swarmauri-sdk/blob/master/contributing.md) that will help you get started.