aspyx-service 0.10.5__tar.gz → 0.10.7__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.

Potentially problematic release.


This version of aspyx-service might be problematic. Click here for more details.

Files changed (31) hide show
  1. {aspyx_service-0.10.5 → aspyx_service-0.10.7}/PKG-INFO +1 -1
  2. {aspyx_service-0.10.5 → aspyx_service-0.10.7}/pyproject.toml +1 -1
  3. {aspyx_service-0.10.5 → aspyx_service-0.10.7}/src/aspyx_service/server.py +66 -7
  4. {aspyx_service-0.10.5 → aspyx_service-0.10.7}/tests/test_service.py +1 -1
  5. {aspyx_service-0.10.5 → aspyx_service-0.10.7}/.gitignore +0 -0
  6. {aspyx_service-0.10.5 → aspyx_service-0.10.7}/LICENSE +0 -0
  7. {aspyx_service-0.10.5 → aspyx_service-0.10.7}/README.md +0 -0
  8. {aspyx_service-0.10.5 → aspyx_service-0.10.7}/performance-test/__init__.py +0 -0
  9. {aspyx_service-0.10.5 → aspyx_service-0.10.7}/performance-test/client.py +0 -0
  10. {aspyx_service-0.10.5 → aspyx_service-0.10.7}/performance-test/config.yaml +0 -0
  11. {aspyx_service-0.10.5 → aspyx_service-0.10.7}/performance-test/main.py +0 -0
  12. {aspyx_service-0.10.5 → aspyx_service-0.10.7}/performance-test/performance-test.py +0 -0
  13. {aspyx_service-0.10.5 → aspyx_service-0.10.7}/performance-test/readme.txt +0 -0
  14. {aspyx_service-0.10.5 → aspyx_service-0.10.7}/performance-test/server.py +0 -0
  15. {aspyx_service-0.10.5 → aspyx_service-0.10.7}/performance-test/start_server_8000.sh +0 -0
  16. {aspyx_service-0.10.5 → aspyx_service-0.10.7}/performance-test/start_server_8001.sh +0 -0
  17. {aspyx_service-0.10.5 → aspyx_service-0.10.7}/src/aspyx_service/__init__.py +0 -0
  18. {aspyx_service-0.10.5 → aspyx_service-0.10.7}/src/aspyx_service/authorization.py +0 -0
  19. {aspyx_service-0.10.5 → aspyx_service-0.10.7}/src/aspyx_service/channels.py +0 -0
  20. {aspyx_service-0.10.5 → aspyx_service-0.10.7}/src/aspyx_service/healthcheck.py +0 -0
  21. {aspyx_service-0.10.5 → aspyx_service-0.10.7}/src/aspyx_service/registries.py +0 -0
  22. {aspyx_service-0.10.5 → aspyx_service-0.10.7}/src/aspyx_service/restchannel.py +0 -0
  23. {aspyx_service-0.10.5 → aspyx_service-0.10.7}/src/aspyx_service/service.py +0 -0
  24. {aspyx_service-0.10.5 → aspyx_service-0.10.7}/src/aspyx_service/session.py +0 -0
  25. {aspyx_service-0.10.5 → aspyx_service-0.10.7}/tests/__init__.py +0 -0
  26. {aspyx_service-0.10.5 → aspyx_service-0.10.7}/tests/common.py +0 -0
  27. {aspyx_service-0.10.5 → aspyx_service-0.10.7}/tests/config.yaml +0 -0
  28. {aspyx_service-0.10.5 → aspyx_service-0.10.7}/tests/test_async_service.py +0 -0
  29. {aspyx_service-0.10.5 → aspyx_service-0.10.7}/tests/test_healthcheck.py +0 -0
  30. {aspyx_service-0.10.5 → aspyx_service-0.10.7}/tests/test_jwt.py +0 -0
  31. {aspyx_service-0.10.5 → aspyx_service-0.10.7}/tests/test_serialization.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aspyx_service
3
- Version: 0.10.5
3
+ Version: 0.10.7
4
4
  Summary: Aspyx Service framework
5
5
  Author-email: Andreas Ernst <andreas.ernst7@gmail.com>
6
6
  License: MIT License
@@ -2,7 +2,7 @@
2
2
 
3
3
  [project]
4
4
  name = "aspyx_service"
5
- version = "0.10.5"
5
+ version = "0.10.7"
6
6
  description = "Aspyx Service framework"
7
7
  authors = [{ name = "Andreas Ernst", email = "andreas.ernst7@gmail.com" }]
8
8
  readme = "README.md"
@@ -6,6 +6,8 @@ import atexit
6
6
  import functools
7
7
  import inspect
8
8
  import threading
9
+ import typing
10
+ from datetime import datetime
9
11
  from typing import Type, Optional, Callable, Any
10
12
  import contextvars
11
13
  import msgpack
@@ -35,12 +37,47 @@ class ResponseContext:
35
37
  class Response:
36
38
  def __init__(self):
37
39
  self.cookies = {}
38
-
39
- def set_cookie(self, key, value):
40
- self.cookies[key] = value
40
+ self.delete_cookies = {}
41
+
42
+ def delete_cookie(self,
43
+ key: str,
44
+ path: str = "/",
45
+ domain: str | None = None,
46
+ secure: bool = False,
47
+ httponly: bool = False,
48
+ samesite: typing.Literal["lax", "strict", "none"] | None = "lax",
49
+ ):
50
+ self.delete_cookies[key] = {
51
+ "path": path,
52
+ "domain": domain,
53
+ "secure": secure,
54
+ "httponly": httponly,
55
+ "samesite": samesite
56
+ }
57
+
58
+ def set_cookie(self,
59
+ key: str,
60
+ value: str = "",
61
+ max_age: int | None = None,
62
+ expires: datetime | str | int | None = None,
63
+ path: str | None = "/",
64
+ domain: str | None = None,
65
+ secure: bool = False,
66
+ httponly: bool = False,
67
+ samesite: typing.Literal["lax", "strict", "none"] | None = "lax"):
68
+ self.cookies[key] = {
69
+ "value": value,
70
+ "max_age": max_age,
71
+ "expires": expires,
72
+ "path": path,
73
+ "domain": domain,
74
+ "secure": secure,
75
+ "httponly": httponly,
76
+ "samesite": samesite
77
+ }
41
78
 
42
79
  @classmethod
43
- def get(cls) -> ResponseContext.Response:
80
+ def create(cls) -> ResponseContext.Response:
44
81
  response = ResponseContext.Response()
45
82
 
46
83
  cls.response_var.set(response)
@@ -48,7 +85,7 @@ class ResponseContext:
48
85
  return response
49
86
 
50
87
  @classmethod
51
- def is_set(cls) -> Optional[ResponseContext.Response]:
88
+ def get(cls) -> Optional[ResponseContext.Response]:
52
89
  return cls.response_var.get()
53
90
 
54
91
  @classmethod
@@ -216,10 +253,32 @@ class FastAPIServer(Server):
216
253
 
217
254
  json_response = JSONResponse(get_serializer(return_type)(result))
218
255
 
219
- local_response = ResponseContext.is_set()
256
+ local_response = ResponseContext.get()
220
257
  if local_response is not None:
258
+ # delete
259
+
260
+ for key, value in local_response.delete_cookies.items():
261
+ json_response.delete_cookie(
262
+ key,
263
+ path=value["path"],
264
+ domain=value["domain"],
265
+ secure=value["secure"],
266
+ httponly=value["httponly"]
267
+ )
268
+
269
+ # create
270
+
221
271
  for key, value in local_response.cookies.items():
222
- json_response.set_cookie(key, value)
272
+ json_response.set_cookie(
273
+ key,
274
+ value=value["value"],
275
+ max_age=value["max_age"],
276
+ expires=value["expires"],
277
+ path=value["path"],
278
+ domain=value["domain"],
279
+ secure=value["secure"],
280
+ httponly=value["httponly"]
281
+ )
223
282
 
224
283
  ResponseContext.reset()
225
284
 
@@ -59,7 +59,7 @@ class TestSyncRemoteService:
59
59
  result_pydantic = test_service.pydantic(pydantic)
60
60
  assert result_pydantic == pydantic
61
61
 
62
- def test_dispatch_rest(self, service_manager):
62
+ def xtest_dispatch_rest(self, service_manager):
63
63
  test_service = service_manager.get_service(TestRestService, preferred_channel="rest")
64
64
 
65
65
  result = test_service.get("hello")
File without changes
File without changes