muffin-rest 7.3.1__py3-none-any.whl → 7.3.3__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.
- muffin_rest/filters.py +4 -4
- muffin_rest/peewee/options.py +3 -3
- muffin_rest/sorting.py +5 -4
- muffin_rest/sqlalchemy/__init__.py +2 -2
- {muffin_rest-7.3.1.dist-info → muffin_rest-7.3.3.dist-info}/METADATA +2 -1
- {muffin_rest-7.3.1.dist-info → muffin_rest-7.3.3.dist-info}/RECORD +8 -8
- {muffin_rest-7.3.1.dist-info → muffin_rest-7.3.3.dist-info}/WHEEL +1 -1
- {muffin_rest-7.3.1.dist-info → muffin_rest-7.3.3.dist-info}/LICENSE +0 -0
muffin_rest/filters.py
CHANGED
|
@@ -38,9 +38,9 @@ class Filter(Mutate):
|
|
|
38
38
|
"$nor": lambda v, c: not any(f(v, c) for f in v),
|
|
39
39
|
}
|
|
40
40
|
operators["<"] = operators["$lt"]
|
|
41
|
-
operators["<="] = operators["$le"]
|
|
41
|
+
operators["<="] = operators["$lte"] = operators["$le"]
|
|
42
42
|
operators[">"] = operators["$gt"]
|
|
43
|
-
operators[">="] = operators["$ge"]
|
|
43
|
+
operators[">="] = operators["$gte"] = operators["$ge"]
|
|
44
44
|
operators["=="] = operators["$eq"]
|
|
45
45
|
operators["!="] = operators["$ne"]
|
|
46
46
|
operators["<<"] = operators["$in"]
|
|
@@ -138,8 +138,8 @@ class Filters(Mutator):
|
|
|
138
138
|
data = json_loads(raw_data)
|
|
139
139
|
assert isinstance(data, dict)
|
|
140
140
|
mutations = self.mutations
|
|
141
|
-
for name in
|
|
142
|
-
if name in
|
|
141
|
+
for name in mutations:
|
|
142
|
+
if name in data:
|
|
143
143
|
ops, collection = await mutations[name].apply(collection, data)
|
|
144
144
|
filters[name] = ops
|
|
145
145
|
|
muffin_rest/peewee/options.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import
|
|
1
|
+
from typing import Type
|
|
2
2
|
|
|
3
3
|
import peewee as pw
|
|
4
4
|
from marshmallow_peewee import ModelSchema
|
|
@@ -27,7 +27,7 @@ class PWRESTOptions(RESTOptions):
|
|
|
27
27
|
base_property: str = "model"
|
|
28
28
|
|
|
29
29
|
model: Type[pw.Model]
|
|
30
|
-
model_pk:
|
|
30
|
+
model_pk: pw.Field
|
|
31
31
|
|
|
32
32
|
manager: Manager
|
|
33
33
|
|
|
@@ -38,7 +38,7 @@ class PWRESTOptions(RESTOptions):
|
|
|
38
38
|
"""Prepare meta options."""
|
|
39
39
|
meta = self.model._meta # type: ignore[]
|
|
40
40
|
self.name = self.name or meta.table_name.lower()
|
|
41
|
-
self.model_pk = self
|
|
41
|
+
self.model_pk = getattr(self, "model_pk", None) or meta.primary_key
|
|
42
42
|
manager = getattr(self, "manager", getattr(self.model, "_manager", None))
|
|
43
43
|
if manager is None:
|
|
44
44
|
raise RuntimeError("Peewee-AIO ORM Manager is not available")
|
muffin_rest/sorting.py
CHANGED
|
@@ -35,7 +35,6 @@ class Sort(Mutate):
|
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
class Sorting(Mutator):
|
|
38
|
-
|
|
39
38
|
"""Build sorters for handlers."""
|
|
40
39
|
|
|
41
40
|
MUTATE_CLASS = Sort
|
|
@@ -54,9 +53,11 @@ class Sorting(Mutator):
|
|
|
54
53
|
sorting = {}
|
|
55
54
|
if data:
|
|
56
55
|
collection = self.prepare(collection)
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
sorting = dict(to_sort(data.split(",")))
|
|
57
|
+
for name in self.mutations:
|
|
58
|
+
sort = self.mutations[name]
|
|
59
|
+
if name in sorting:
|
|
60
|
+
desc = sorting[name]
|
|
60
61
|
collection = await sort.apply(collection, desc=desc)
|
|
61
62
|
sorting[sort.name] = desc
|
|
62
63
|
|
|
@@ -77,7 +77,7 @@ class SARESTOptions(RESTOptions):
|
|
|
77
77
|
schema_base: Type[SQLAlchemyAutoSchema] = SQLAlchemyAutoSchema
|
|
78
78
|
|
|
79
79
|
table: sa.Table
|
|
80
|
-
table_pk:
|
|
80
|
+
table_pk: sa.Column
|
|
81
81
|
database: Database
|
|
82
82
|
|
|
83
83
|
base_property = "table"
|
|
@@ -88,7 +88,7 @@ class SARESTOptions(RESTOptions):
|
|
|
88
88
|
raise ValueError("'SARESTHandler.Meta.database' is required")
|
|
89
89
|
|
|
90
90
|
self.name = self.name or self.table.name
|
|
91
|
-
self.table_pk = self
|
|
91
|
+
self.table_pk = getattr(self, "table_pk", None) or self.table.c.id
|
|
92
92
|
|
|
93
93
|
super().setup(cls)
|
|
94
94
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: muffin-rest
|
|
3
|
-
Version: 7.3.
|
|
3
|
+
Version: 7.3.3
|
|
4
4
|
Summary: The package provides enhanced support for writing REST APIs with Muffin framework
|
|
5
5
|
Home-page: https://github.com/klen/muffin-rest
|
|
6
6
|
License: MIT
|
|
@@ -19,6 +19,7 @@ Classifier: Programming Language :: Python :: 3.8
|
|
|
19
19
|
Classifier: Programming Language :: Python :: 3.9
|
|
20
20
|
Classifier: Programming Language :: Python :: 3.10
|
|
21
21
|
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
23
|
Classifier: Topic :: Internet :: WWW/HTTP
|
|
23
24
|
Provides-Extra: peewee
|
|
24
25
|
Provides-Extra: sqlalchemy
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
muffin_rest/__init__.py,sha256=NBZeOEJgQHtFFhVgd9d0fpApFRgU405sbm0cu1y1MOU,1242
|
|
2
2
|
muffin_rest/api.py,sha256=gCqRb5PgKEMkE84Y0ZnJw_laVRmVWZRxzBqBv0ns6w8,3882
|
|
3
3
|
muffin_rest/errors.py,sha256=TIXSADZYSwx70dOVPRAzuNwGLfpLuzZZ1ugMZMwIGDo,1169
|
|
4
|
-
muffin_rest/filters.py,sha256=
|
|
4
|
+
muffin_rest/filters.py,sha256=lMnPMdy7h0nB9bH-Nf5Hv_qenAGzG0V3ULpizTK3OnM,5623
|
|
5
5
|
muffin_rest/handler.py,sha256=LcPFFH01nwe2tYKYbq-KVDX5UBVMlaRmeisJ_s4jsCo,10035
|
|
6
6
|
muffin_rest/marshmallow.py,sha256=hHPLTLdaSz5jTLWBqyHeOwo2xfBv7aMIuJFD_trHRuE,715
|
|
7
7
|
muffin_rest/mongo/__init__.py,sha256=unoEAKCU9H3EKhQqKGosn02tTS3H5nPOcTd3THM4Qs8,4675
|
|
@@ -16,22 +16,22 @@ muffin_rest/peewee/__init__.py,sha256=94DSj_ftT6fbPksHlBv40AH2HWaiZommUFOMN2jd9a
|
|
|
16
16
|
muffin_rest/peewee/filters.py,sha256=ziqpD7uH9vzx_yHKUpOYmduNmM8w-8b7CtRaSoCqECU,2382
|
|
17
17
|
muffin_rest/peewee/handler.py,sha256=O84-TmiyNyEhEamTh-DY93ds0hZJzVG8_yekRpF9p3k,5359
|
|
18
18
|
muffin_rest/peewee/openapi.py,sha256=ZZuh7nJVuK9cTJqtOJ_XASe9iJgter-xIjj9YJ8xszI,1111
|
|
19
|
-
muffin_rest/peewee/options.py,sha256=
|
|
19
|
+
muffin_rest/peewee/options.py,sha256=F-UjCbz5rAIXt-D_MtmriiYkOL7wsri6FRt7WCNZzyo,1480
|
|
20
20
|
muffin_rest/peewee/schemas.py,sha256=6xaNxKFpdXjoiPFI9yc0tBN7B535A2IFLRE9x6unrZM,1215
|
|
21
21
|
muffin_rest/peewee/sorting.py,sha256=jLU9d9h8uCV61NbsjkdhDLvh0lCK_6Os-0kIOI-pKwc,1983
|
|
22
22
|
muffin_rest/peewee/types.py,sha256=cgCXhpGHkImKwudA1lulZHz5oJswHH168AiW5MhZRCM,155
|
|
23
23
|
muffin_rest/peewee/utils.py,sha256=wXeneVE1IZl1ROnY28re73H62Y1_tEmoEQYzPhuOyBI,702
|
|
24
24
|
muffin_rest/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
25
25
|
muffin_rest/redoc.html,sha256=GtuHIMvTuSi8Ro6bgI-G8VB94AljMyfjcZseqtBmGCY,559
|
|
26
|
-
muffin_rest/sorting.py,sha256=
|
|
27
|
-
muffin_rest/sqlalchemy/__init__.py,sha256=
|
|
26
|
+
muffin_rest/sorting.py,sha256=Z3echqt8ve-p1f7iOVYlFFVsA3ShCXVaXDkVMFTC6tQ,2887
|
|
27
|
+
muffin_rest/sqlalchemy/__init__.py,sha256=WYxb5d4eQqXeT8MwpgdiItAjrOdFm-_5GaG-xtWQ4lk,6362
|
|
28
28
|
muffin_rest/sqlalchemy/filters.py,sha256=bTT7ndx_d0YaDSviDfpzwN9T46dQrV9WbeG8YH9KVBg,2466
|
|
29
29
|
muffin_rest/sqlalchemy/sorting.py,sha256=YlFKpIet4TUy7fJ2UBLC8b9lAOwY66QBpPDDApbyh8M,1643
|
|
30
30
|
muffin_rest/sqlalchemy/types.py,sha256=JnIw44XJ2ClWzOv-mTUrvFw1JPxAlvdX_jf7r4zau-s,204
|
|
31
31
|
muffin_rest/swagger.html,sha256=2uGLu_KpkYf925KnDKHBJmV9pm6OHn5C3BWScESsUS8,1736
|
|
32
32
|
muffin_rest/types.py,sha256=vy55ShzMcvs9zXjFpdjWlagv09dMrcmxb2-U4hTL3NM,521
|
|
33
33
|
muffin_rest/utils.py,sha256=WT87AHXvBFBzBVTkwsYmDXgG3ZX1wNKFo4SOUJ9JiQY,2095
|
|
34
|
-
muffin_rest-7.3.
|
|
35
|
-
muffin_rest-7.3.
|
|
36
|
-
muffin_rest-7.3.
|
|
37
|
-
muffin_rest-7.3.
|
|
34
|
+
muffin_rest-7.3.3.dist-info/LICENSE,sha256=xHPkOZhjyKBMOwXpWn9IB_BVLjrrMxv2M9slKkHj2hM,1082
|
|
35
|
+
muffin_rest-7.3.3.dist-info/METADATA,sha256=dZjxmTrL0K9ELOwvzmANu2dLtDfwumqkaQOOIDazLcE,4177
|
|
36
|
+
muffin_rest-7.3.3.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
37
|
+
muffin_rest-7.3.3.dist-info/RECORD,,
|
|
File without changes
|