clear-skies 1.22.4__py3-none-any.whl → 1.22.6__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.
Potentially problematic release.
This version of clear-skies might be problematic. Click here for more details.
- {clear_skies-1.22.4.dist-info → clear_skies-1.22.6.dist-info}/METADATA +1 -1
- {clear_skies-1.22.4.dist-info → clear_skies-1.22.6.dist-info}/RECORD +8 -8
- clearskies/backends/__init__.py +2 -0
- clearskies/backends/api_get_only_backend.py +18 -71
- clearskies/column_types/audit.py +1 -0
- clearskies/column_types/has_many.py +5 -1
- {clear_skies-1.22.4.dist-info → clear_skies-1.22.6.dist-info}/LICENSE +0 -0
- {clear_skies-1.22.4.dist-info → clear_skies-1.22.6.dist-info}/WHEEL +0 -0
|
@@ -45,9 +45,9 @@ clearskies/autodoc/schema/number.py,sha256=aw1UcA2fdgWL8ao8mbpgd5DgI50c9hli9U8GJ
|
|
|
45
45
|
clearskies/autodoc/schema/object.py,sha256=GJ5zLw2CzhezQiNuIhVgRyk0esXqfHD5fxZrcn3tUow,383
|
|
46
46
|
clearskies/autodoc/schema/password.py,sha256=Ptj8OeddAL4h69KWqZ6ubZ2awR13xdDIrNe2N0T1jic,196
|
|
47
47
|
clearskies/autodoc/schema/string.py,sha256=oxZPCxYYhWnNHdbtwD3QuniStbj8XbBBpDTFXgPR1VU,244
|
|
48
|
-
clearskies/backends/__init__.py,sha256=
|
|
48
|
+
clearskies/backends/__init__.py,sha256=ATNzuDYREx-VBWemPmG95FR8EzO2X0--7tkErUuF9Qc,832
|
|
49
49
|
clearskies/backends/api_backend.py,sha256=PQyT00pMtZZUQhfWySzVbXZ2GpycO93CRKVOmUFeo10,15073
|
|
50
|
-
clearskies/backends/api_get_only_backend.py,sha256=
|
|
50
|
+
clearskies/backends/api_get_only_backend.py,sha256=KfFF72l31KBK--90lIkDqE5gcTnolSkShUqNaaWZ_gc,1690
|
|
51
51
|
clearskies/backends/backend.py,sha256=fkL-De0MUdzcS2JG_spSUQZIVL9oRFvaL6SP26JPpcI,7399
|
|
52
52
|
clearskies/backends/cursor_backend.py,sha256=VntlPS6z6bnZOC3XRJ-WFf5gK3pFUhH_qJpnZn8hl9U,11278
|
|
53
53
|
clearskies/backends/example_backend.py,sha256=jVpv0LZpNUEJGko0XqioLkHmZHbCW6M4YyNvzKlZcDw,1413
|
|
@@ -58,7 +58,7 @@ clearskies/backends/restful_api_advanced_search_backend.py,sha256=kBHO7wO_b24pkD
|
|
|
58
58
|
clearskies/backends/secrets_backend.py,sha256=4lzrgdL_O_pgCT5HknV2gotFgp9GzjQ5_2n0-4H4kvs,2204
|
|
59
59
|
clearskies/binding_config.py,sha256=bF8LBNEgJacwKCqToAtDqN9hv5omzU7zt_4qB9KPtE0,457
|
|
60
60
|
clearskies/column_types/__init__.py,sha256=wofhLfyW00I6tb6o9DMsMx7j9hlbbqefhDzWfw0Row0,4731
|
|
61
|
-
clearskies/column_types/audit.py,sha256=
|
|
61
|
+
clearskies/column_types/audit.py,sha256=K908Gv2GBt8LOsAqz7RLCpyByeLoq1gFT7EOcMAnkQ8,9676
|
|
62
62
|
clearskies/column_types/belongs_to.py,sha256=E7Wi84vr2PnNw7TBCoZa8jkpwiJhO-iQmZ_ekq26kTs,12206
|
|
63
63
|
clearskies/column_types/boolean.py,sha256=1yyM1CUfgD84pPE65c1OP1Qjf_J0Z45hjPrDR51AUkQ,1878
|
|
64
64
|
clearskies/column_types/category_tree.py,sha256=kPx0fNTJxHaaEI_-0JxQ7NBcV2bYgUDGmtf1wmTqoEg,13172
|
|
@@ -74,7 +74,7 @@ clearskies/column_types/datetime.py,sha256=xtuZpUC9fA16i1oO80kPIx--8RDPuei9RdsDD
|
|
|
74
74
|
clearskies/column_types/datetime_micro.py,sha256=ewQSniCc2MmNIyX2XNuNcCIwh5Fpf1HcvpLfzB8lz8g,382
|
|
75
75
|
clearskies/column_types/email.py,sha256=qq0Yo_C3KxUqT68q2HWXocBBR4xwMqjxcIdgZRv218U,584
|
|
76
76
|
clearskies/column_types/float.py,sha256=j8jJeBueSOusPtAFCWgLHYBncfLnqT1U7bh1zcAkYiA,1332
|
|
77
|
-
clearskies/column_types/has_many.py,sha256=
|
|
77
|
+
clearskies/column_types/has_many.py,sha256=hQYV5I-mmC8-u_O225AP_2ylNQONQZ8dAr1P-XjdAO0,7521
|
|
78
78
|
clearskies/column_types/has_one.py,sha256=uphIPUuHLwwmhljLMaKKPujR6TYTT7onn-hHUF6S_IY,2230
|
|
79
79
|
clearskies/column_types/integer.py,sha256=dGIluusPmhLRNg7PplOJLbQI2AXojqRBUHt8ekYWNVI,1386
|
|
80
80
|
clearskies/column_types/json.py,sha256=TbZkdwCoZYhbALUxof2jENGfaq2i5TlcyBcmo7XzDGQ,652
|
|
@@ -207,7 +207,7 @@ clearskies/tests/simple_api/models/__init__.py,sha256=nUA0W6fgXw_Bxa9CudkaDkC80t
|
|
|
207
207
|
clearskies/tests/simple_api/models/status.py,sha256=PEhPbaQh5qdUNHp8O0gz91LOLENAEBtqSaHxUPXchaM,699
|
|
208
208
|
clearskies/tests/simple_api/models/user.py,sha256=5_P4Tp1tTdX7PkMJ__epPM5MA7JAeVYGas69vcWloLc,819
|
|
209
209
|
clearskies/tests/simple_api/users_api.py,sha256=KYXCgEofDxHeRdQK67txN5oYUPvxxmB8JTku7L-apk4,2344
|
|
210
|
-
clear_skies-1.22.
|
|
211
|
-
clear_skies-1.22.
|
|
212
|
-
clear_skies-1.22.
|
|
213
|
-
clear_skies-1.22.
|
|
210
|
+
clear_skies-1.22.6.dist-info/LICENSE,sha256=3Ehd0g3YOpCj8sqj0Xjq5qbOtjjgk9qzhhD9YjRQgOA,1053
|
|
211
|
+
clear_skies-1.22.6.dist-info/METADATA,sha256=T5O-efftiQQCctIXwnfYcXY82tA06-pZkXWSk-I5zAQ,1817
|
|
212
|
+
clear_skies-1.22.6.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
|
|
213
|
+
clear_skies-1.22.6.dist-info/RECORD,,
|
clearskies/backends/__init__.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from .. import binding_config
|
|
2
2
|
from .api_backend import ApiBackend
|
|
3
|
+
from .api_get_only_backend import ApiGetOnlyBackend
|
|
3
4
|
from .backend import Backend
|
|
4
5
|
from .cursor_backend import CursorBackend
|
|
5
6
|
from .example_backend import ExampleBackend
|
|
@@ -16,6 +17,7 @@ def example_backend(data):
|
|
|
16
17
|
|
|
17
18
|
__all__ = [
|
|
18
19
|
"ApiBackend",
|
|
20
|
+
"ApiGetOnlyBackend",
|
|
19
21
|
"Backend",
|
|
20
22
|
"CursorBackend",
|
|
21
23
|
"ExampleBackend",
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
from .api_backend import ApiBackend
|
|
2
|
-
from typing import Any,
|
|
3
|
-
from .. import model
|
|
2
|
+
from typing import Any, Dict
|
|
4
3
|
|
|
5
4
|
|
|
6
5
|
class ApiGetOnlyBackend(ApiBackend):
|
|
@@ -18,84 +17,32 @@ class ApiGetOnlyBackend(ApiBackend):
|
|
|
18
17
|
def __init__(self, requests):
|
|
19
18
|
self._requests = requests
|
|
20
19
|
|
|
21
|
-
def configure(self, auth=None, origin=
|
|
20
|
+
def configure(self, auth=None, origin="", id_column_name="id"):
|
|
22
21
|
self._auth = auth
|
|
23
22
|
self._origin = origin
|
|
24
23
|
self._id_column_name = id_column_name
|
|
25
24
|
|
|
26
25
|
def records_url(self, configuration):
|
|
26
|
+
if not len(configuration["wheres"]):
|
|
27
|
+
raise ValueError(
|
|
28
|
+
f"When using the {self.__class__.__name__} backend, you must search the model by the id column. A records request was executed but no search conditions were found."
|
|
29
|
+
)
|
|
27
30
|
record_id = None
|
|
28
31
|
for where in configuration["wheres"]:
|
|
29
|
-
if where["column"] ==
|
|
32
|
+
if where["column"] == self._id_column_name:
|
|
30
33
|
record_id = where["values"][0]
|
|
31
|
-
if record_id:
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
if not record_id:
|
|
35
|
+
raise ValueError(
|
|
36
|
+
f"When using the {self.__class__.__name__} backend, you must search by the id column ('{self._id_column_name}'). A records request was executed but there was no condition set for the '{self._id_column_name}' column"
|
|
37
|
+
)
|
|
34
38
|
|
|
35
|
-
|
|
36
|
-
table_name = model.table_name().rstrip("/")
|
|
37
|
-
return f"{table_name}/{id}"
|
|
38
|
-
|
|
39
|
-
def update_url(self, id: str, model: model.Model) -> str:
|
|
40
|
-
table_name = model.table_name().rstrip("/")
|
|
41
|
-
return f"{table_name}/{id}"
|
|
42
|
-
|
|
43
|
-
def create_url(self, data: Dict[str, Any], model: model.Model) -> str:
|
|
44
|
-
return model.table_name().rstrip("/")
|
|
39
|
+
return self._origin + configuration["table_name"].strip("/") + f"/{record_id}"
|
|
45
40
|
|
|
46
41
|
def records_method(self, configuration: Dict[str, Any]) -> str:
|
|
47
|
-
return "
|
|
48
|
-
|
|
49
|
-
def count_method(self, configuration: Dict[str, Any]) -> str:
|
|
50
|
-
return "POST"
|
|
51
|
-
|
|
52
|
-
def _build_delete_request(self, id, model):
|
|
53
|
-
data = model.data
|
|
54
|
-
(url, data) = self._finalize_url_and_data(self.delete_url(id, model), data)
|
|
55
|
-
return [url, self.delete_method(id, model), {}, {}]
|
|
56
|
-
|
|
57
|
-
def _build_count_request(self, configuration):
|
|
58
|
-
[url, method, json_data, headers] = super()._build_count_request(configuration)
|
|
59
|
-
json_data["count_only"] = True
|
|
60
|
-
return [url, method, json_data, headers]
|
|
61
|
-
|
|
62
|
-
def records(self, configuration, model, next_page_data={}):
|
|
63
|
-
configuration = self._check_query_configuration(configuration)
|
|
64
|
-
[url, method, json_data, headers] = self._build_records_request(configuration)
|
|
65
|
-
response = self._execute_request(url, method, json=json_data, headers=headers).json()
|
|
66
|
-
records = self._map_records_response(response)
|
|
67
|
-
for next_page_key in ["nextPage", "NextPage", "next_page"]:
|
|
68
|
-
if response.get("pagination", {}).get(next_page_key):
|
|
69
|
-
for key, value in response["pagination"][next_page_key].items():
|
|
70
|
-
next_page_data[key] = value
|
|
71
|
-
return records
|
|
72
|
-
|
|
73
|
-
def _as_post_data(self, configuration):
|
|
74
|
-
data = {
|
|
75
|
-
"where": list(
|
|
76
|
-
map(lambda where: self._where_for_post(where, configuration["model_columns"]), configuration["wheres"])
|
|
77
|
-
),
|
|
78
|
-
"sort": configuration["sorts"],
|
|
79
|
-
"start": configuration["pagination"].get("start", 0),
|
|
80
|
-
"limit": configuration["limit"],
|
|
81
|
-
}
|
|
82
|
-
return {key: value for (key, value) in data.items() if value}
|
|
83
|
-
|
|
84
|
-
def _where_for_post(self, where, columns):
|
|
85
|
-
prefix = ""
|
|
86
|
-
if where.get("table"):
|
|
87
|
-
prefix = where["table"] + "."
|
|
88
|
-
return {
|
|
89
|
-
"column": prefix + where["column"],
|
|
90
|
-
"operator": where["operator"],
|
|
91
|
-
"value": self.normalize_outgoing_value(where, columns, where["values"][0]),
|
|
92
|
-
}
|
|
42
|
+
return "GET"
|
|
93
43
|
|
|
94
|
-
def
|
|
95
|
-
|
|
96
|
-
if
|
|
97
|
-
return
|
|
98
|
-
|
|
99
|
-
if column_name in normalized_data:
|
|
100
|
-
return normalized_data[column_name]
|
|
101
|
-
return value
|
|
44
|
+
def _map_records_response(self, json):
|
|
45
|
+
response = super()._map_records_response(json)
|
|
46
|
+
if isinstance(response, dict):
|
|
47
|
+
return [response]
|
|
48
|
+
return response
|
clearskies/column_types/audit.py
CHANGED
|
@@ -143,7 +143,11 @@ class HasMany(Column):
|
|
|
143
143
|
@property
|
|
144
144
|
def child_models(self):
|
|
145
145
|
children = self.di.build(self.config("child_models_class"), cache=True)
|
|
146
|
-
|
|
146
|
+
wheres = self.config("where", silent=True)
|
|
147
|
+
if not wheres:
|
|
148
|
+
return children
|
|
149
|
+
|
|
150
|
+
for index, where in enumerate(wheres):
|
|
147
151
|
if callable(where):
|
|
148
152
|
children = self.di.call_function(where, model=children)
|
|
149
153
|
if not children:
|
|
File without changes
|
|
File without changes
|