muffin-rest 12.0.3__tar.gz → 13.0.1__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.
Files changed (39) hide show
  1. {muffin_rest-12.0.3 → muffin_rest-13.0.1}/PKG-INFO +1 -1
  2. {muffin_rest-12.0.3 → muffin_rest-13.0.1}/muffin_rest/handler.py +2 -2
  3. {muffin_rest-12.0.3 → muffin_rest-13.0.1}/muffin_rest/mongo/__init__.py +3 -3
  4. {muffin_rest-12.0.3 → muffin_rest-13.0.1}/muffin_rest/openapi.py +1 -1
  5. {muffin_rest-12.0.3 → muffin_rest-13.0.1}/muffin_rest/peewee/handler.py +3 -3
  6. {muffin_rest-12.0.3 → muffin_rest-13.0.1}/muffin_rest/peewee/openapi.py +1 -1
  7. {muffin_rest-12.0.3 → muffin_rest-13.0.1}/muffin_rest/sqlalchemy/__init__.py +6 -6
  8. {muffin_rest-12.0.3 → muffin_rest-13.0.1}/pyproject.toml +1 -1
  9. {muffin_rest-12.0.3 → muffin_rest-13.0.1}/LICENSE +0 -0
  10. {muffin_rest-12.0.3 → muffin_rest-13.0.1}/README.md +0 -0
  11. {muffin_rest-12.0.3 → muffin_rest-13.0.1}/muffin_rest/__init__.py +0 -0
  12. {muffin_rest-12.0.3 → muffin_rest-13.0.1}/muffin_rest/api.py +0 -0
  13. {muffin_rest-12.0.3 → muffin_rest-13.0.1}/muffin_rest/errors.py +0 -0
  14. {muffin_rest-12.0.3 → muffin_rest-13.0.1}/muffin_rest/filters.py +0 -0
  15. {muffin_rest-12.0.3 → muffin_rest-13.0.1}/muffin_rest/limits.py +0 -0
  16. {muffin_rest-12.0.3 → muffin_rest-13.0.1}/muffin_rest/marshmallow.py +0 -0
  17. {muffin_rest-12.0.3 → muffin_rest-13.0.1}/muffin_rest/mongo/filters.py +0 -0
  18. {muffin_rest-12.0.3 → muffin_rest-13.0.1}/muffin_rest/mongo/schema.py +0 -0
  19. {muffin_rest-12.0.3 → muffin_rest-13.0.1}/muffin_rest/mongo/sorting.py +0 -0
  20. {muffin_rest-12.0.3 → muffin_rest-13.0.1}/muffin_rest/mongo/types.py +0 -0
  21. {muffin_rest-12.0.3 → muffin_rest-13.0.1}/muffin_rest/mongo/utils.py +0 -0
  22. {muffin_rest-12.0.3 → muffin_rest-13.0.1}/muffin_rest/options.py +0 -0
  23. {muffin_rest-12.0.3 → muffin_rest-13.0.1}/muffin_rest/peewee/__init__.py +0 -0
  24. {muffin_rest-12.0.3 → muffin_rest-13.0.1}/muffin_rest/peewee/filters.py +0 -0
  25. {muffin_rest-12.0.3 → muffin_rest-13.0.1}/muffin_rest/peewee/options.py +0 -0
  26. {muffin_rest-12.0.3 → muffin_rest-13.0.1}/muffin_rest/peewee/schemas.py +0 -0
  27. {muffin_rest-12.0.3 → muffin_rest-13.0.1}/muffin_rest/peewee/sorting.py +0 -0
  28. {muffin_rest-12.0.3 → muffin_rest-13.0.1}/muffin_rest/peewee/types.py +0 -0
  29. {muffin_rest-12.0.3 → muffin_rest-13.0.1}/muffin_rest/peewee/utils.py +0 -0
  30. {muffin_rest-12.0.3 → muffin_rest-13.0.1}/muffin_rest/py.typed +0 -0
  31. {muffin_rest-12.0.3 → muffin_rest-13.0.1}/muffin_rest/redoc.html +0 -0
  32. {muffin_rest-12.0.3 → muffin_rest-13.0.1}/muffin_rest/schemas.py +0 -0
  33. {muffin_rest-12.0.3 → muffin_rest-13.0.1}/muffin_rest/sorting.py +0 -0
  34. {muffin_rest-12.0.3 → muffin_rest-13.0.1}/muffin_rest/sqlalchemy/filters.py +0 -0
  35. {muffin_rest-12.0.3 → muffin_rest-13.0.1}/muffin_rest/sqlalchemy/sorting.py +0 -0
  36. {muffin_rest-12.0.3 → muffin_rest-13.0.1}/muffin_rest/sqlalchemy/types.py +0 -0
  37. {muffin_rest-12.0.3 → muffin_rest-13.0.1}/muffin_rest/swagger.html +0 -0
  38. {muffin_rest-12.0.3 → muffin_rest-13.0.1}/muffin_rest/types.py +0 -0
  39. {muffin_rest-12.0.3 → muffin_rest-13.0.1}/muffin_rest/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: muffin-rest
3
- Version: 12.0.3
3
+ Version: 13.0.1
4
4
  Summary: The package provides enhanced support for writing REST APIs with Muffin framework
5
5
  License: MIT
6
6
  Keywords: rest,api,muffin,asgi,asyncio,trio
@@ -82,7 +82,7 @@ class RESTBase(Generic[TVResource], Handler, metaclass=RESTHandlerMeta):
82
82
 
83
83
  else:
84
84
  router.bind(cls, f"/{ cls.meta.name }", methods=methods, **params)
85
- router.bind(cls, f"/{ cls.meta.name }/{{pk}}", methods=methods, **params)
85
+ router.bind(cls, f"/{ cls.meta.name }/{{id}}", methods=methods, **params)
86
86
 
87
87
  for _, method in inspect.getmembers(cls, lambda m: hasattr(m, "__route__")):
88
88
  paths, methods = method.__route__
@@ -147,7 +147,7 @@ class RESTBase(Generic[TVResource], Handler, metaclass=RESTHandlerMeta):
147
147
 
148
148
  async def prepare_resource(self, request: Request) -> Any:
149
149
  """Load a resource."""
150
- return request["path_params"].get("pk")
150
+ return request["path_params"].get("id")
151
151
 
152
152
  async def filter(self, request: Request, collection: TVCollection) -> tuple[TVCollection, Any]:
153
153
  """Filter the collection."""
@@ -86,13 +86,13 @@ class MongoRESTHandler(RESTHandler[TVResource]):
86
86
 
87
87
  async def prepare_resource(self, request: Request) -> TVResource | None:
88
88
  """Load a resource."""
89
- pk = request["path_params"].get("pk")
90
- if not pk:
89
+ key = request["path_params"].get("id")
90
+ if not key:
91
91
  return None
92
92
 
93
93
  try:
94
94
  return await self.collection.find_one(
95
- {self.meta.collection_id: bson.ObjectId(pk)},
95
+ {self.meta.collection_id: bson.ObjectId(key)},
96
96
  )
97
97
  except InvalidId as exc:
98
98
  raise APIError.NOT_FOUND() from exc
@@ -199,7 +199,7 @@ class OpenAPIMixin:
199
199
  schema_ref = {"$ref": f"#/components/schemas/{ meta.Schema.__name__ }"}
200
200
  for method in route_to_methods(route):
201
201
  operations[method] = {"tags": [tags[cls]]}
202
- is_resource_route = isinstance(route, DynamicRoute) and route.params.get("pk")
202
+ is_resource_route = isinstance(route, DynamicRoute) and route.params.get("id")
203
203
 
204
204
  if method == "get" and not is_resource_route:
205
205
  operations[method]["parameters"] = []
@@ -58,15 +58,15 @@ class PWRESTBase(RESTBase[TVModel], PeeweeOpenAPIMixin):
58
58
 
59
59
  async def prepare_resource(self, request: Request) -> TVModel | None:
60
60
  """Load a resource."""
61
- pk = request["path_params"].get("pk")
62
- if not pk:
61
+ key = request["path_params"].get("id")
62
+ if not key:
63
63
  return None
64
64
 
65
65
  meta = self.meta
66
66
 
67
67
  try:
68
68
  resource = await meta.manager.fetchone(
69
- self.collection.where(meta.model_pk == pk),
69
+ self.collection.where(meta.model_pk == key),
70
70
  )
71
71
  except Exception: # noqa: BLE001
72
72
  resource = None
@@ -22,7 +22,7 @@ class PeeweeOpenAPIMixin(OpenAPIMixin):
22
22
  def openapi(cls, route: Route, spec: APISpec, tags: dict) -> dict:
23
23
  """Get openapi specs for the endpoint."""
24
24
  operations = super(PeeweeOpenAPIMixin, cls).openapi(route, spec, tags)
25
- is_resource_route = getattr(route, "params", {}).get("pk")
25
+ is_resource_route = getattr(route, "params", {}).get("id")
26
26
  if not is_resource_route and "delete" in operations:
27
27
  operations["delete"].setdefault("parameters", [])
28
28
  operations["delete"]["requestBody"] = {
@@ -143,11 +143,11 @@ class SARESTHandler(RESTHandler[TVResource]):
143
143
 
144
144
  async def prepare_resource(self, request: Request) -> TVResource | None:
145
145
  """Load a resource."""
146
- pk = request["path_params"].get("pk")
147
- if not pk:
146
+ key = request["path_params"].get("id")
147
+ if not key:
148
148
  return None
149
149
 
150
- qs = self.collection.where(self.meta.table_pk == pk)
150
+ qs = self.collection.where(self.meta.table_pk == key)
151
151
  resource = await self.meta.database.fetch_one(qs)
152
152
  if resource is None:
153
153
  raise APIError.NOT_FOUND("Resource not found")
@@ -176,11 +176,11 @@ class SARESTHandler(RESTHandler[TVResource]):
176
176
  async def remove(self, request: Request, resource: TVResource | None = None):
177
177
  """Remove the given resource."""
178
178
  table_pk = cast("sa.Column", self.meta.table_pk)
179
- pks = [resource[table_pk.name]] if resource else await request.data()
180
- if not pks:
179
+ keys = [resource[table_pk.name]] if resource else await request.data()
180
+ if not keys:
181
181
  raise APIError.NOT_FOUND()
182
182
 
183
- delete = self.meta.table.delete().where(table_pk.in_(cast("list[Any]", pks)))
183
+ delete = self.meta.table.delete().where(table_pk.in_(cast("list[Any]", keys)))
184
184
  await self.meta.database.execute(delete)
185
185
 
186
186
  delete = remove
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "muffin-rest"
3
- version = "12.0.3"
3
+ version = "13.0.1"
4
4
  description = "The package provides enhanced support for writing REST APIs with Muffin framework"
5
5
  readme = "README.md"
6
6
  homepage = "https://github.com/klen/muffin-rest"
File without changes
File without changes