statikk 0.1.5__py3-none-any.whl → 0.1.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.
- statikk/models.py +19 -3
- {statikk-0.1.5.dist-info → statikk-0.1.6.dist-info}/METADATA +1 -1
- {statikk-0.1.5.dist-info → statikk-0.1.6.dist-info}/RECORD +6 -6
- {statikk-0.1.5.dist-info → statikk-0.1.6.dist-info}/WHEEL +1 -1
- {statikk-0.1.5.dist-info → statikk-0.1.6.dist-info}/LICENSE.txt +0 -0
- {statikk-0.1.5.dist-info → statikk-0.1.6.dist-info}/top_level.txt +0 -0
statikk/models.py
CHANGED
@@ -67,16 +67,18 @@ class TrackingMixin:
|
|
67
67
|
|
68
68
|
def _recursive_hash(self) -> int:
|
69
69
|
"""
|
70
|
-
Compute a hash value for the model, ignoring nested DatabaseModel instances.
|
70
|
+
Compute a hash value for the model, ignoring specified fields and nested DatabaseModel instances.
|
71
71
|
|
72
|
-
This ensures that changes to child models don't affect the parent's hash.
|
72
|
+
This ensures that changes to ignored fields or child models don't affect the parent's hash.
|
73
73
|
|
74
74
|
Returns:
|
75
|
-
A hash value representing the model's non-
|
75
|
+
A hash value representing the model's non-ignored fields.
|
76
76
|
"""
|
77
77
|
if not self.should_track:
|
78
78
|
return 0
|
79
79
|
|
80
|
+
ignored_fields = self.ignore_tracking_fields()
|
81
|
+
|
80
82
|
values = []
|
81
83
|
for field_name in self.model_fields:
|
82
84
|
if not hasattr(self, field_name):
|
@@ -85,6 +87,9 @@ class TrackingMixin:
|
|
85
87
|
if field_name.startswith("_"):
|
86
88
|
continue
|
87
89
|
|
90
|
+
if field_name in ignored_fields:
|
91
|
+
continue
|
92
|
+
|
88
93
|
value = getattr(self, field_name)
|
89
94
|
|
90
95
|
if hasattr(value, "__class__") and issubclass(value.__class__, DatabaseModel):
|
@@ -141,6 +146,17 @@ class TrackingMixin:
|
|
141
146
|
|
142
147
|
return True
|
143
148
|
|
149
|
+
def ignore_tracking_fields(self) -> set:
|
150
|
+
"""
|
151
|
+
Override this method to specify fields to ignore when tracking changes.
|
152
|
+
|
153
|
+
Returns:
|
154
|
+
A set specifying fields to ignore.
|
155
|
+
Example:
|
156
|
+
{"field1", "field2"}
|
157
|
+
"""
|
158
|
+
return {}
|
159
|
+
|
144
160
|
|
145
161
|
class DatabaseModel(BaseModel, TrackingMixin, extra=Extra.allow):
|
146
162
|
id: str = Field(default_factory=lambda: str(uuid4()))
|
@@ -3,10 +3,10 @@ statikk/conditions.py,sha256=63FYMR-UUaE-ZJEb_8CU721CQTwhajq39-BbokmKeMA,2166
|
|
3
3
|
statikk/engine.py,sha256=U2STo-d8Rf6jiPtIdVgGdZ11G6xYjn-yehFdeCb7ZO8,30961
|
4
4
|
statikk/expressions.py,sha256=mF6Hmj3Kmj6KKXTymeTHSepVA7rhiSINpFgSAPeBTRY,12210
|
5
5
|
statikk/fields.py,sha256=LkMP5NnX7WS0HSLxI3Q-dMOrfaJ0SD7SayZxJU5Acgg,86
|
6
|
-
statikk/models.py,sha256=
|
6
|
+
statikk/models.py,sha256=jc6Ta0-jSwE5mAMd2703EyKVKrG6VGqLStpYCCxYaKs,13762
|
7
7
|
statikk/typing.py,sha256=qfpegORcdODuILK3gvuD4SdcZA1a7Myn0yvscOLPHOM,68
|
8
|
-
statikk-0.1.
|
9
|
-
statikk-0.1.
|
10
|
-
statikk-0.1.
|
11
|
-
statikk-0.1.
|
12
|
-
statikk-0.1.
|
8
|
+
statikk-0.1.6.dist-info/LICENSE.txt,sha256=uSH_2Hpb2Bigy5_HhBliN2fZbBU64G3ERM5zzhKPUEE,1078
|
9
|
+
statikk-0.1.6.dist-info/METADATA,sha256=K99ceCXlXRr3soKTtKxLEXUQKspay_LyNhYcgFUdJc0,3160
|
10
|
+
statikk-0.1.6.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
|
11
|
+
statikk-0.1.6.dist-info/top_level.txt,sha256=etKmBbjzIlLpSefXoiOfhWGEgvqUEALaFwCjFDBD9YI,8
|
12
|
+
statikk-0.1.6.dist-info/RECORD,,
|
File without changes
|
File without changes
|