clear-skies 2.0.0__py3-none-any.whl → 2.0.2__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-2.0.0.dist-info → clear_skies-2.0.2.dist-info}/METADATA +2 -2
- {clear_skies-2.0.0.dist-info → clear_skies-2.0.2.dist-info}/RECORD +78 -77
- clearskies/__init__.py +5 -8
- clearskies/authentication/authentication.py +4 -0
- clearskies/authentication/authorization.py +4 -0
- clearskies/authentication/jwks.py +8 -3
- clearskies/authentication/secret_bearer.py +3 -3
- clearskies/backends/api_backend.py +2 -2
- clearskies/backends/backend.py +13 -0
- clearskies/backends/secrets_backend.py +0 -1
- clearskies/column.py +9 -8
- clearskies/columns/audit.py +3 -2
- clearskies/columns/belongs_to_id.py +2 -2
- clearskies/columns/belongs_to_model.py +6 -2
- clearskies/columns/belongs_to_self.py +2 -2
- clearskies/columns/boolean.py +6 -2
- clearskies/columns/category_tree.py +2 -2
- clearskies/columns/category_tree_children.py +2 -2
- clearskies/columns/created.py +3 -2
- clearskies/columns/created_by_authorization_data.py +2 -2
- clearskies/columns/created_by_header.py +2 -2
- clearskies/columns/created_by_ip.py +2 -2
- clearskies/columns/created_by_routing_data.py +3 -2
- clearskies/columns/created_by_user_agent.py +2 -2
- clearskies/columns/date.py +6 -2
- clearskies/columns/datetime.py +6 -2
- clearskies/columns/float.py +6 -2
- clearskies/columns/has_many.py +2 -2
- clearskies/columns/has_many_self.py +2 -2
- clearskies/columns/integer.py +6 -2
- clearskies/columns/json.py +6 -2
- clearskies/columns/many_to_many_ids.py +6 -2
- clearskies/columns/many_to_many_ids_with_data.py +6 -2
- clearskies/columns/many_to_many_models.py +6 -2
- clearskies/columns/many_to_many_pivots.py +3 -2
- clearskies/columns/phone.py +3 -2
- clearskies/columns/select.py +3 -2
- clearskies/columns/string.py +4 -0
- clearskies/columns/timestamp.py +6 -2
- clearskies/columns/updated.py +2 -2
- clearskies/columns/uuid.py +2 -2
- clearskies/configs/__init__.py +4 -1
- clearskies/configs/config.py +4 -1
- clearskies/configs/endpoint_list.py +28 -0
- clearskies/contexts/cli.py +4 -0
- clearskies/contexts/context.py +13 -0
- clearskies/contexts/wsgi.py +4 -0
- clearskies/contexts/wsgi_ref.py +4 -0
- clearskies/{parameters_to_properties.py → decorators.py} +2 -0
- clearskies/di/di.py +2 -2
- clearskies/di/injectable_properties.py +2 -2
- clearskies/endpoint.py +7 -6
- clearskies/endpoint_group.py +14 -1
- clearskies/endpoints/callable.py +5 -4
- clearskies/endpoints/create.py +1 -1
- clearskies/endpoints/delete.py +1 -1
- clearskies/endpoints/get.py +1 -1
- clearskies/endpoints/health_check.py +1 -1
- clearskies/endpoints/list.py +1 -1
- clearskies/endpoints/restful_api.py +2 -2
- clearskies/endpoints/simple_search.py +1 -1
- clearskies/endpoints/update.py +1 -1
- clearskies/model.py +1214 -64
- clearskies/query/query.py +4 -4
- clearskies/security_header.py +7 -0
- clearskies/security_headers/cache_control.py +2 -2
- clearskies/security_headers/cors.py +2 -2
- clearskies/security_headers/csp.py +2 -2
- clearskies/security_headers/hsts.py +2 -2
- clearskies/validator.py +12 -0
- clearskies/validators/after_column.py +2 -2
- clearskies/validators/in_the_future.py +1 -1
- clearskies/validators/in_the_past.py +1 -1
- clearskies/validators/required.py +0 -1
- clearskies/validators/timedelta.py +2 -2
- clearskies/validators/unique.py +0 -1
- {clear_skies-2.0.0.dist-info → clear_skies-2.0.2.dist-info}/LICENSE +0 -0
- {clear_skies-2.0.0.dist-info → clear_skies-2.0.2.dist-info}/WHEEL +0 -0
|
@@ -2,7 +2,7 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
from typing import TYPE_CHECKING, Self, overload
|
|
4
4
|
|
|
5
|
-
import clearskies.
|
|
5
|
+
import clearskies.decorators
|
|
6
6
|
from clearskies import configs
|
|
7
7
|
from clearskies.column import Column
|
|
8
8
|
from clearskies.columns import CategoryTree
|
|
@@ -36,7 +36,7 @@ class CategoryTreeChildren(Column):
|
|
|
36
36
|
is_searchable = configs.Boolean(default=False)
|
|
37
37
|
_descriptor_config_map = None
|
|
38
38
|
|
|
39
|
-
@clearskies.
|
|
39
|
+
@clearskies.decorators.parameters_to_properties
|
|
40
40
|
def __init__(
|
|
41
41
|
self,
|
|
42
42
|
category_tree_column_name: str,
|
clearskies/columns/created.py
CHANGED
|
@@ -3,9 +3,10 @@ from __future__ import annotations
|
|
|
3
3
|
import datetime
|
|
4
4
|
from typing import TYPE_CHECKING, Any
|
|
5
5
|
|
|
6
|
+
import clearskies.decorators
|
|
6
7
|
import clearskies.di
|
|
7
8
|
import clearskies.typing
|
|
8
|
-
from clearskies import configs
|
|
9
|
+
from clearskies import configs
|
|
9
10
|
from clearskies.columns.datetime import Datetime
|
|
10
11
|
|
|
11
12
|
if TYPE_CHECKING:
|
|
@@ -67,7 +68,7 @@ class Created(Datetime):
|
|
|
67
68
|
|
|
68
69
|
now = clearskies.di.inject.Now()
|
|
69
70
|
|
|
70
|
-
@
|
|
71
|
+
@clearskies.decorators.parameters_to_properties
|
|
71
72
|
def __init__(
|
|
72
73
|
self,
|
|
73
74
|
date_format: str = "%Y-%m-%d %H:%M:%S",
|
|
@@ -2,7 +2,7 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
from typing import TYPE_CHECKING, Any
|
|
4
4
|
|
|
5
|
-
import clearskies.
|
|
5
|
+
import clearskies.decorators
|
|
6
6
|
import clearskies.typing
|
|
7
7
|
from clearskies import configs
|
|
8
8
|
from clearskies.columns.string import String
|
|
@@ -100,7 +100,7 @@ class CreatedByAuthorizationData(String):
|
|
|
100
100
|
|
|
101
101
|
_allowed_search_operators = ["=", "in", "is not null", "is null", "like"]
|
|
102
102
|
|
|
103
|
-
@clearskies.
|
|
103
|
+
@clearskies.decorators.parameters_to_properties
|
|
104
104
|
def __init__(
|
|
105
105
|
self,
|
|
106
106
|
authorization_data_key_name: str,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import clearskies.
|
|
1
|
+
import clearskies.decorators
|
|
2
2
|
import clearskies.typing
|
|
3
3
|
from clearskies import configs
|
|
4
4
|
from clearskies.columns.string import String
|
|
@@ -83,7 +83,7 @@ class CreatedByHeader(String):
|
|
|
83
83
|
|
|
84
84
|
_allowed_search_operators = ["=", "in", "is not null", "is null", "like"]
|
|
85
85
|
|
|
86
|
-
@clearskies.
|
|
86
|
+
@clearskies.decorators.parameters_to_properties
|
|
87
87
|
def __init__(
|
|
88
88
|
self,
|
|
89
89
|
header_name: str,
|
|
@@ -2,7 +2,7 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
from typing import TYPE_CHECKING, Any
|
|
4
4
|
|
|
5
|
-
import clearskies.
|
|
5
|
+
import clearskies.decorators
|
|
6
6
|
import clearskies.typing
|
|
7
7
|
from clearskies import configs
|
|
8
8
|
from clearskies.columns.string import String
|
|
@@ -70,7 +70,7 @@ class CreatedByIp(String):
|
|
|
70
70
|
|
|
71
71
|
_allowed_search_operators = ["=", "in", "is not null", "is null", "like"]
|
|
72
72
|
|
|
73
|
-
@clearskies.
|
|
73
|
+
@clearskies.decorators.parameters_to_properties
|
|
74
74
|
def __init__(
|
|
75
75
|
self,
|
|
76
76
|
is_readable: bool = True,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import clearskies.decorators
|
|
1
2
|
import clearskies.typing
|
|
2
|
-
from clearskies import configs
|
|
3
|
+
from clearskies import configs
|
|
3
4
|
from clearskies.columns.string import String
|
|
4
5
|
|
|
5
6
|
|
|
@@ -80,7 +81,7 @@ class CreatedByRoutingData(String):
|
|
|
80
81
|
|
|
81
82
|
_allowed_search_operators = ["=", "in", "is not null", "is null", "like"]
|
|
82
83
|
|
|
83
|
-
@
|
|
84
|
+
@clearskies.decorators.parameters_to_properties
|
|
84
85
|
def __init__(
|
|
85
86
|
self,
|
|
86
87
|
routing_path_name: str,
|
|
@@ -3,7 +3,7 @@ from __future__ import annotations
|
|
|
3
3
|
import datetime
|
|
4
4
|
from typing import TYPE_CHECKING, Any
|
|
5
5
|
|
|
6
|
-
import clearskies.
|
|
6
|
+
import clearskies.decorators
|
|
7
7
|
import clearskies.typing
|
|
8
8
|
from clearskies import configs
|
|
9
9
|
from clearskies.columns.string import String
|
|
@@ -70,7 +70,7 @@ class CreatedByUserAgent(String):
|
|
|
70
70
|
|
|
71
71
|
_allowed_search_operators = ["=", "in", "is not null", "is null", "like"]
|
|
72
72
|
|
|
73
|
-
@clearskies.
|
|
73
|
+
@clearskies.decorators.parameters_to_properties
|
|
74
74
|
def __init__(
|
|
75
75
|
self,
|
|
76
76
|
is_readable: bool = True,
|
clearskies/columns/date.py
CHANGED
|
@@ -5,7 +5,7 @@ from typing import TYPE_CHECKING, Any, Callable, Self, overload
|
|
|
5
5
|
|
|
6
6
|
import dateparser # type: ignore
|
|
7
7
|
|
|
8
|
-
import clearskies.
|
|
8
|
+
import clearskies.decorators
|
|
9
9
|
import clearskies.typing
|
|
10
10
|
from clearskies import configs
|
|
11
11
|
from clearskies.autodoc.schema import Datetime as AutoDocDatetime
|
|
@@ -102,7 +102,7 @@ class Date(Datetime):
|
|
|
102
102
|
auto_doc_class: type[AutoDocSchema] = AutoDocDatetime
|
|
103
103
|
_descriptor_config_map = None
|
|
104
104
|
|
|
105
|
-
@clearskies.
|
|
105
|
+
@clearskies.decorators.parameters_to_properties
|
|
106
106
|
def __init__(
|
|
107
107
|
self,
|
|
108
108
|
date_format: str = "%Y-%m-%d",
|
|
@@ -162,6 +162,10 @@ class Date(Datetime):
|
|
|
162
162
|
return super().__get__(instance, cls)
|
|
163
163
|
|
|
164
164
|
def __set__(self, instance, value: datetime.datetime | datetime.date) -> None:
|
|
165
|
+
# this makes sure we're initialized
|
|
166
|
+
if "name" not in self._config: # type: ignore
|
|
167
|
+
instance.get_columns()
|
|
168
|
+
|
|
165
169
|
instance._next_data[self.name] = value
|
|
166
170
|
|
|
167
171
|
def equals(self, value: str | datetime.datetime | datetime.date) -> Condition:
|
clearskies/columns/datetime.py
CHANGED
|
@@ -5,7 +5,7 @@ from typing import TYPE_CHECKING, Any, Callable, Self, overload
|
|
|
5
5
|
|
|
6
6
|
import dateparser # type: ignore
|
|
7
7
|
|
|
8
|
-
import clearskies.
|
|
8
|
+
import clearskies.decorators
|
|
9
9
|
import clearskies.typing
|
|
10
10
|
from clearskies import configs
|
|
11
11
|
from clearskies.autodoc.schema import Datetime as AutoDocDatetime
|
|
@@ -127,7 +127,7 @@ class Datetime(Column):
|
|
|
127
127
|
auto_doc_class: type[AutoDocSchema] = AutoDocDatetime
|
|
128
128
|
_descriptor_config_map = None
|
|
129
129
|
|
|
130
|
-
@clearskies.
|
|
130
|
+
@clearskies.decorators.parameters_to_properties
|
|
131
131
|
def __init__(
|
|
132
132
|
self,
|
|
133
133
|
date_format: str = "%Y-%m-%d %H:%M:%S",
|
|
@@ -204,6 +204,10 @@ class Datetime(Column):
|
|
|
204
204
|
return super().__get__(instance, cls)
|
|
205
205
|
|
|
206
206
|
def __set__(self, instance, value: datetime.datetime) -> None:
|
|
207
|
+
# this makes sure we're initialized
|
|
208
|
+
if "name" not in self._config: # type: ignore
|
|
209
|
+
instance.get_columns()
|
|
210
|
+
|
|
207
211
|
instance._next_data[self.name] = value
|
|
208
212
|
|
|
209
213
|
def equals(self, value: str | datetime.datetime) -> Condition:
|
clearskies/columns/float.py
CHANGED
|
@@ -2,7 +2,7 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
from typing import TYPE_CHECKING, Callable, Self, overload
|
|
4
4
|
|
|
5
|
-
import clearskies.
|
|
5
|
+
import clearskies.decorators
|
|
6
6
|
import clearskies.typing
|
|
7
7
|
from clearskies import configs
|
|
8
8
|
from clearskies.autodoc.schema import Number as AutoDocNumber
|
|
@@ -75,7 +75,7 @@ class Float(Column):
|
|
|
75
75
|
auto_doc_class: type[AutoDocSchema] = AutoDocNumber
|
|
76
76
|
_descriptor_config_map = None
|
|
77
77
|
|
|
78
|
-
@clearskies.
|
|
78
|
+
@clearskies.decorators.parameters_to_properties
|
|
79
79
|
def __init__(
|
|
80
80
|
self,
|
|
81
81
|
default: float | None = None,
|
|
@@ -106,6 +106,10 @@ class Float(Column):
|
|
|
106
106
|
return super().__get__(instance, cls)
|
|
107
107
|
|
|
108
108
|
def __set__(self, instance, value: float) -> None:
|
|
109
|
+
# this makes sure we're initialized
|
|
110
|
+
if "name" not in self._config: # type: ignore
|
|
111
|
+
instance.get_columns()
|
|
112
|
+
|
|
109
113
|
instance._next_data[self.name] = float(value)
|
|
110
114
|
|
|
111
115
|
def from_backend(self, value) -> float:
|
clearskies/columns/has_many.py
CHANGED
|
@@ -2,7 +2,7 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
from typing import TYPE_CHECKING, Any, Self, overload
|
|
4
4
|
|
|
5
|
-
import clearskies.
|
|
5
|
+
import clearskies.decorators
|
|
6
6
|
import clearskies.typing
|
|
7
7
|
from clearskies import configs
|
|
8
8
|
from clearskies.autodoc.schema import Array as AutoDocArray
|
|
@@ -382,7 +382,7 @@ class HasMany(Column):
|
|
|
382
382
|
|
|
383
383
|
input_output = InputOutput()
|
|
384
384
|
|
|
385
|
-
@clearskies.
|
|
385
|
+
@clearskies.decorators.parameters_to_properties
|
|
386
386
|
def __init__(
|
|
387
387
|
self,
|
|
388
388
|
child_model_class,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import clearskies.decorators
|
|
1
2
|
import clearskies.typing
|
|
2
|
-
from clearskies import parameters_to_properties
|
|
3
3
|
from clearskies.columns.has_many import HasMany
|
|
4
4
|
|
|
5
5
|
|
|
@@ -20,7 +20,7 @@ class HasManySelf(HasMany):
|
|
|
20
20
|
|
|
21
21
|
_descriptor_config_map = None
|
|
22
22
|
|
|
23
|
-
@
|
|
23
|
+
@clearskies.decorators.parameters_to_properties
|
|
24
24
|
def __init__(
|
|
25
25
|
self,
|
|
26
26
|
foreign_column_name: str | None = None,
|
clearskies/columns/integer.py
CHANGED
|
@@ -2,7 +2,7 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
from typing import TYPE_CHECKING, Callable, Self, overload
|
|
4
4
|
|
|
5
|
-
import clearskies.
|
|
5
|
+
import clearskies.decorators
|
|
6
6
|
import clearskies.typing
|
|
7
7
|
from clearskies import configs
|
|
8
8
|
from clearskies.autodoc.schema import Integer as AutoDocInteger
|
|
@@ -77,7 +77,7 @@ class Integer(Column):
|
|
|
77
77
|
|
|
78
78
|
_descriptor_config_map = None
|
|
79
79
|
|
|
80
|
-
@clearskies.
|
|
80
|
+
@clearskies.decorators.parameters_to_properties
|
|
81
81
|
def __init__(
|
|
82
82
|
self,
|
|
83
83
|
default: int | None = None,
|
|
@@ -113,6 +113,10 @@ class Integer(Column):
|
|
|
113
113
|
return None if value is None else int(value)
|
|
114
114
|
|
|
115
115
|
def __set__(self, instance, value: int) -> None:
|
|
116
|
+
# this makes sure we're initialized
|
|
117
|
+
if "name" not in self._config: # type: ignore
|
|
118
|
+
instance.get_columns()
|
|
119
|
+
|
|
116
120
|
instance._next_data[self.name] = value
|
|
117
121
|
|
|
118
122
|
def from_backend(self, value) -> int | None:
|
clearskies/columns/json.py
CHANGED
|
@@ -3,7 +3,7 @@ from __future__ import annotations
|
|
|
3
3
|
import json
|
|
4
4
|
from typing import TYPE_CHECKING, Any, Callable, Self, overload
|
|
5
5
|
|
|
6
|
-
import clearskies.
|
|
6
|
+
import clearskies.decorators
|
|
7
7
|
import clearskies.typing
|
|
8
8
|
from clearskies import configs
|
|
9
9
|
from clearskies.column import Column
|
|
@@ -72,7 +72,7 @@ class Json(Column):
|
|
|
72
72
|
is_searchable = configs.Boolean(default=False)
|
|
73
73
|
_descriptor_config_map = None
|
|
74
74
|
|
|
75
|
-
@clearskies.
|
|
75
|
+
@clearskies.decorators.parameters_to_properties
|
|
76
76
|
def __init__(
|
|
77
77
|
self,
|
|
78
78
|
default: dict[str, Any] | None = None,
|
|
@@ -102,6 +102,10 @@ class Json(Column):
|
|
|
102
102
|
return super().__get__(instance, cls)
|
|
103
103
|
|
|
104
104
|
def __set__(self, instance, value: dict[str, Any]) -> None:
|
|
105
|
+
# this makes sure we're initialized
|
|
106
|
+
if "name" not in self._config: # type: ignore
|
|
107
|
+
instance.get_columns()
|
|
108
|
+
|
|
105
109
|
instance._next_data[self.name] = value
|
|
106
110
|
|
|
107
111
|
def from_backend(self, value) -> dict[str, Any] | list[Any] | None:
|
|
@@ -3,7 +3,7 @@ from __future__ import annotations
|
|
|
3
3
|
from collections import OrderedDict
|
|
4
4
|
from typing import TYPE_CHECKING, Any, Callable, Self, overload
|
|
5
5
|
|
|
6
|
-
import clearskies.
|
|
6
|
+
import clearskies.decorators
|
|
7
7
|
import clearskies.typing
|
|
8
8
|
from clearskies import configs
|
|
9
9
|
from clearskies.autodoc.schema import Array as AutoDocArray
|
|
@@ -173,7 +173,7 @@ class ManyToManyIds(Column):
|
|
|
173
173
|
is_searchable = configs.Boolean(default=False)
|
|
174
174
|
_descriptor_config_map = None
|
|
175
175
|
|
|
176
|
-
@clearskies.
|
|
176
|
+
@clearskies.decorators.parameters_to_properties
|
|
177
177
|
def __init__(
|
|
178
178
|
self,
|
|
179
179
|
related_model_class,
|
|
@@ -258,6 +258,10 @@ class ManyToManyIds(Column):
|
|
|
258
258
|
return [getattr(model, related_id_column_name) for model in self.get_related_models(instance)]
|
|
259
259
|
|
|
260
260
|
def __set__(self, instance, value: list[str | int]) -> None:
|
|
261
|
+
# this makes sure we're initialized
|
|
262
|
+
if "name" not in self._config: # type: ignore
|
|
263
|
+
instance.get_columns()
|
|
264
|
+
|
|
261
265
|
instance._next_data[self.name] = value
|
|
262
266
|
|
|
263
267
|
def get_related_models(self, model: Model) -> Model:
|
|
@@ -2,7 +2,7 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
from typing import TYPE_CHECKING, Any, Callable, Self, overload
|
|
4
4
|
|
|
5
|
-
import clearskies.
|
|
5
|
+
import clearskies.decorators
|
|
6
6
|
import clearskies.typing
|
|
7
7
|
from clearskies import configs
|
|
8
8
|
from clearskies.columns.many_to_many_ids import ManyToManyIds
|
|
@@ -149,7 +149,7 @@ class ManyToManyIdsWithData(ManyToManyIds):
|
|
|
149
149
|
setable = configs.ListAnyDictOrCallable(default=None) # type: ignore
|
|
150
150
|
_descriptor_config_map = None
|
|
151
151
|
|
|
152
|
-
@clearskies.
|
|
152
|
+
@clearskies.decorators.parameters_to_properties
|
|
153
153
|
def __init__(
|
|
154
154
|
self,
|
|
155
155
|
related_model_class,
|
|
@@ -187,6 +187,10 @@ class ManyToManyIdsWithData(ManyToManyIds):
|
|
|
187
187
|
return super().__get__(instance, cls)
|
|
188
188
|
|
|
189
189
|
def __set__(self, instance, value: list[dict[str, Any]]) -> None: # type: ignore
|
|
190
|
+
# this makes sure we're initialized
|
|
191
|
+
if "name" not in self._config: # type: ignore
|
|
192
|
+
instance.get_columns()
|
|
193
|
+
|
|
190
194
|
instance._next_data[self.name] = value
|
|
191
195
|
|
|
192
196
|
def post_save(self, data, model, id):
|
|
@@ -3,7 +3,7 @@ from __future__ import annotations
|
|
|
3
3
|
from collections import OrderedDict
|
|
4
4
|
from typing import TYPE_CHECKING, Any, Callable, Self, overload
|
|
5
5
|
|
|
6
|
-
import clearskies.
|
|
6
|
+
import clearskies.decorators
|
|
7
7
|
import clearskies.typing
|
|
8
8
|
from clearskies import configs
|
|
9
9
|
from clearskies.autodoc.schema import Array as AutoDocArray
|
|
@@ -30,7 +30,7 @@ class ManyToManyModels(Column):
|
|
|
30
30
|
is_searchable = configs.Boolean(default=False)
|
|
31
31
|
_descriptor_config_map = None
|
|
32
32
|
|
|
33
|
-
@clearskies.
|
|
33
|
+
@clearskies.decorators.parameters_to_properties
|
|
34
34
|
def __init__(
|
|
35
35
|
self,
|
|
36
36
|
many_to_many_column_name,
|
|
@@ -87,6 +87,10 @@ class ManyToManyModels(Column):
|
|
|
87
87
|
return self.many_to_many_column.get_related_models(instance) # type: ignore
|
|
88
88
|
|
|
89
89
|
def __set__(self, instance, value: Model | list[Model] | list[dict[str, Any]]) -> None:
|
|
90
|
+
# this makes sure we're initialized
|
|
91
|
+
if "name" not in self._config: # type: ignore
|
|
92
|
+
instance.get_columns()
|
|
93
|
+
|
|
90
94
|
# we allow a list of models or a model, but if it's a model it may represent a single record or a query.
|
|
91
95
|
# if it's a single record then we want to wrap it in a list so we can iterate over it.
|
|
92
96
|
if hasattr(value, "_data") and value._data:
|
|
@@ -3,8 +3,9 @@ from __future__ import annotations
|
|
|
3
3
|
from collections import OrderedDict
|
|
4
4
|
from typing import TYPE_CHECKING, Any, Callable, Self, overload
|
|
5
5
|
|
|
6
|
+
import clearskies.decorators
|
|
6
7
|
import clearskies.typing
|
|
7
|
-
from clearskies import configs
|
|
8
|
+
from clearskies import configs
|
|
8
9
|
from clearskies.autodoc.schema import Array as AutoDocArray
|
|
9
10
|
from clearskies.autodoc.schema import Object as AutoDocObject
|
|
10
11
|
from clearskies.column import Column
|
|
@@ -30,7 +31,7 @@ class ManyToManyPivots(Column):
|
|
|
30
31
|
is_searchable = configs.Boolean(default=False)
|
|
31
32
|
_descriptor_config_map = None
|
|
32
33
|
|
|
33
|
-
@
|
|
34
|
+
@clearskies.decorators.parameters_to_properties
|
|
34
35
|
def __init__(
|
|
35
36
|
self,
|
|
36
37
|
many_to_many_column_name,
|
clearskies/columns/phone.py
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import re
|
|
2
2
|
from typing import Any, Callable
|
|
3
3
|
|
|
4
|
+
import clearskies.decorators
|
|
4
5
|
import clearskies.typing
|
|
5
|
-
from clearskies import configs
|
|
6
|
+
from clearskies import configs
|
|
6
7
|
from clearskies.columns.string import String
|
|
7
8
|
|
|
8
9
|
|
|
@@ -98,7 +99,7 @@ class Phone(String):
|
|
|
98
99
|
usa_only = configs.Boolean(default=True)
|
|
99
100
|
_descriptor_config_map = None
|
|
100
101
|
|
|
101
|
-
@
|
|
102
|
+
@clearskies.decorators.parameters_to_properties
|
|
102
103
|
def __init__(
|
|
103
104
|
self,
|
|
104
105
|
usa_only: bool = True,
|
clearskies/columns/select.py
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
from typing import Callable
|
|
2
2
|
|
|
3
|
+
import clearskies.decorators
|
|
3
4
|
import clearskies.typing
|
|
4
|
-
from clearskies import configs
|
|
5
|
+
from clearskies import configs
|
|
5
6
|
from clearskies.columns.string import String
|
|
6
7
|
|
|
7
8
|
|
|
@@ -67,7 +68,7 @@ class Select(String):
|
|
|
67
68
|
allowed_values = configs.StringList(required=True)
|
|
68
69
|
_descriptor_config_map = None
|
|
69
70
|
|
|
70
|
-
@
|
|
71
|
+
@clearskies.decorators.parameters_to_properties
|
|
71
72
|
def __init__(
|
|
72
73
|
self,
|
|
73
74
|
allowed_values: list[str],
|
clearskies/columns/string.py
CHANGED
|
@@ -92,6 +92,10 @@ class String(Column):
|
|
|
92
92
|
return instance._transformed_data[self.name]
|
|
93
93
|
|
|
94
94
|
def __set__(self, instance: Model, value: str) -> None:
|
|
95
|
+
# this makes sure we're initialized
|
|
96
|
+
if "name" not in self._config: # type: ignore
|
|
97
|
+
instance.get_columns()
|
|
98
|
+
|
|
95
99
|
instance._next_data[self.name] = value
|
|
96
100
|
|
|
97
101
|
def input_error_for_value(self, value: str, operator: str | None = None) -> str:
|
clearskies/columns/timestamp.py
CHANGED
|
@@ -3,7 +3,7 @@ from __future__ import annotations
|
|
|
3
3
|
import datetime
|
|
4
4
|
from typing import TYPE_CHECKING, Any, Callable, Self, Type, overload
|
|
5
5
|
|
|
6
|
-
import clearskies.
|
|
6
|
+
import clearskies.decorators
|
|
7
7
|
import clearskies.typing
|
|
8
8
|
from clearskies import configs
|
|
9
9
|
from clearskies.columns.datetime import Datetime
|
|
@@ -76,7 +76,7 @@ class Timestamp(Datetime):
|
|
|
76
76
|
include_microseconds = configs.Boolean(default=False)
|
|
77
77
|
_descriptor_config_map = None
|
|
78
78
|
|
|
79
|
-
@clearskies.
|
|
79
|
+
@clearskies.decorators.parameters_to_properties
|
|
80
80
|
def __init__(
|
|
81
81
|
self,
|
|
82
82
|
include_microseconds: bool = False,
|
|
@@ -148,6 +148,10 @@ class Timestamp(Datetime):
|
|
|
148
148
|
return super().__get__(instance, cls)
|
|
149
149
|
|
|
150
150
|
def __set__(self, instance, value: datetime.datetime) -> None:
|
|
151
|
+
# this makes sure we're initialized
|
|
152
|
+
if "name" not in self._config: # type: ignore
|
|
153
|
+
instance.get_columns()
|
|
154
|
+
|
|
151
155
|
instance._next_data[self.name] = value
|
|
152
156
|
|
|
153
157
|
def input_error_for_value(self, value: str, operator: str | None = None) -> str:
|
clearskies/columns/updated.py
CHANGED
|
@@ -3,8 +3,8 @@ from __future__ import annotations
|
|
|
3
3
|
import datetime
|
|
4
4
|
from typing import TYPE_CHECKING, Any
|
|
5
5
|
|
|
6
|
+
import clearskies.decorators
|
|
6
7
|
import clearskies.di
|
|
7
|
-
import clearskies.parameters_to_properties
|
|
8
8
|
import clearskies.typing
|
|
9
9
|
from clearskies import configs
|
|
10
10
|
from clearskies.columns.datetime import Datetime
|
|
@@ -85,7 +85,7 @@ class Updated(Datetime):
|
|
|
85
85
|
|
|
86
86
|
now = clearskies.di.inject.Now()
|
|
87
87
|
|
|
88
|
-
@clearskies.
|
|
88
|
+
@clearskies.decorators.parameters_to_properties
|
|
89
89
|
def __init__(
|
|
90
90
|
self,
|
|
91
91
|
in_utc: bool = True,
|
clearskies/columns/uuid.py
CHANGED
|
@@ -2,8 +2,8 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
from typing import TYPE_CHECKING, Any
|
|
4
4
|
|
|
5
|
+
import clearskies.decorators
|
|
5
6
|
import clearskies.di
|
|
6
|
-
import clearskies.parameters_to_properties
|
|
7
7
|
import clearskies.typing
|
|
8
8
|
from clearskies import configs
|
|
9
9
|
from clearskies.columns.string import String
|
|
@@ -65,7 +65,7 @@ class Uuid(String):
|
|
|
65
65
|
|
|
66
66
|
uuid = clearskies.di.inject.Uuid()
|
|
67
67
|
|
|
68
|
-
@clearskies.
|
|
68
|
+
@clearskies.decorators.parameters_to_properties
|
|
69
69
|
def __init__(
|
|
70
70
|
self,
|
|
71
71
|
is_readable: bool = True,
|
clearskies/configs/__init__.py
CHANGED
|
@@ -56,7 +56,7 @@ class MyConfigurableClass(configs.Configurable):
|
|
|
56
56
|
age = configs.Integer(required=True)
|
|
57
57
|
property_with_default = configs.String(default="some value")
|
|
58
58
|
|
|
59
|
-
@clearskies.
|
|
59
|
+
@clearskies.decorators()
|
|
60
60
|
def __init__(self, name: str, age: int, optional: string = None):
|
|
61
61
|
self.finalize_and_validate_configuration()
|
|
62
62
|
```
|
|
@@ -80,6 +80,7 @@ from .config import Config
|
|
|
80
80
|
from .datetime import Datetime
|
|
81
81
|
from .datetime_or_callable import DatetimeOrCallable
|
|
82
82
|
from .endpoint import Endpoint
|
|
83
|
+
from .endpoint_list import EndpointList
|
|
83
84
|
from .float import Float
|
|
84
85
|
from .float_or_callable import FloatOrCallable
|
|
85
86
|
from .integer import Integer
|
|
@@ -126,6 +127,8 @@ __all__ = [
|
|
|
126
127
|
"Config",
|
|
127
128
|
"Datetime",
|
|
128
129
|
"DatetimeOrCallable",
|
|
130
|
+
"Endpoint",
|
|
131
|
+
"EndpointList",
|
|
129
132
|
"Float",
|
|
130
133
|
"FloatOrCallable",
|
|
131
134
|
"Joins",
|
clearskies/configs/config.py
CHANGED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import TYPE_CHECKING
|
|
4
|
+
|
|
5
|
+
from clearskies.configs import config
|
|
6
|
+
|
|
7
|
+
if TYPE_CHECKING:
|
|
8
|
+
from clearskies.endpoint import Endpoint as EndpointBase
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class EndpointList(config.Config):
|
|
12
|
+
def __set__(self, instance, value: list[EndpointBase]):
|
|
13
|
+
if not isinstance(value, list):
|
|
14
|
+
raise TypeError(
|
|
15
|
+
f"{error_prefix} attempt to set a value of type '{value.__class__.__name__}' to a parameter that requries a list of endpoints."
|
|
16
|
+
)
|
|
17
|
+
for index, item in enumerate(value):
|
|
18
|
+
if not hasattr(item, "top_level_authentication_and_authorization"):
|
|
19
|
+
error_prefix = self._error_prefix(instance)
|
|
20
|
+
raise TypeError(
|
|
21
|
+
f"{error_prefix} attempt to set a value of type '{item.__class__.__name__}' for item #{index+1} when all items in the list should be instances of clearskies.End."
|
|
22
|
+
)
|
|
23
|
+
instance._set_config(self, value)
|
|
24
|
+
|
|
25
|
+
def __get__(self, instance, parent) -> list[EndpointBase]:
|
|
26
|
+
if not instance:
|
|
27
|
+
return self # type: ignore
|
|
28
|
+
return instance._get_config(self)
|
clearskies/contexts/cli.py
CHANGED
clearskies/contexts/context.py
CHANGED
|
@@ -15,8 +15,21 @@ if TYPE_CHECKING:
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
class Context:
|
|
18
|
+
"""
|
|
19
|
+
Context: a flexible way to connect applications to hosting strategies.
|
|
20
|
+
"""
|
|
21
|
+
|
|
18
22
|
di: Di = None # type: ignore
|
|
19
23
|
|
|
24
|
+
"""
|
|
25
|
+
The application to execute.
|
|
26
|
+
|
|
27
|
+
This can be a callable, an endpoint, or an endpoint group. If passed a callable, the callable can request any
|
|
28
|
+
standard or defined dependencies and should return the desired response. It can also raise any exception from
|
|
29
|
+
clearskies.exceptions.
|
|
30
|
+
"""
|
|
31
|
+
application: Callable | clearskies.endpoint.Endpoint | clearskies.endpoint_group.EndpointGroup = None # type: ignore
|
|
32
|
+
|
|
20
33
|
def __init__(
|
|
21
34
|
self,
|
|
22
35
|
application: Callable | clearskies.endpoint.Endpoint | clearskies.endpoint_group.EndpointGroup,
|
clearskies/contexts/wsgi.py
CHANGED
|
@@ -12,5 +12,9 @@ from clearskies.input_outputs import Wsgi as WsgiInputOutput
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
class Wsgi(Context):
|
|
15
|
+
"""
|
|
16
|
+
Connect your application to a WSGI server.
|
|
17
|
+
"""
|
|
18
|
+
|
|
15
19
|
def __call__(self, env, start_response): # type: ignore
|
|
16
20
|
return self.execute_application(WsgiInputOutput(env, start_response))
|
clearskies/contexts/wsgi_ref.py
CHANGED