ramifice 0.8.15__py3-none-any.whl → 0.8.17__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.
ramifice/models/model.py CHANGED
@@ -188,3 +188,14 @@ class Model(metaclass=ABCMeta):
188
188
  elif group == "id":
189
189
  value = ObjectId(value)
190
190
  self.__dict__[name].value = value
191
+
192
+ # --------------------------------------------------------------------------
193
+ def get_clean_data(self) -> tuple[dict[str, Any], dict[str, str]]:
194
+ """Get clean data."""
195
+ clean_data: dict[str, Any] = {}
196
+
197
+ for name, data in self.__dict__.items():
198
+ if not callable(data):
199
+ clean_data[name] = data.value
200
+
201
+ return (clean_data, {})
@@ -65,7 +65,7 @@ class CheckMixin(
65
65
 
66
66
  result_map: dict[str, Any] = {}
67
67
  # Errors from additional validation of fields.
68
- error_map: dict[str, str] = await self.add_validation() or {}
68
+ error_map: dict[str, str] = await self.add_validation()
69
69
  # Get Model collection.
70
70
  if collection is None:
71
71
  collection = constants.MONGO_DATABASE[cls_model.META["collection_name"]]
@@ -10,5 +10,4 @@ class AddValidMixin(metaclass=ABCMeta):
10
10
 
11
11
  async def add_validation(self) -> dict[str, str]:
12
12
  """Ramifice - Additional validation of fields."""
13
- error_map: dict[str, str] = {}
14
- return error_map
13
+ return {}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ramifice
3
- Version: 0.8.15
3
+ Version: 0.8.17
4
4
  Summary: ORM-pseudo-like API MongoDB for Python language.
5
5
  Project-URL: Homepage, https://github.com/kebasyaty/ramifice
6
6
  Project-URL: Documentation, https://kebasyaty.github.io/ramifice/
@@ -132,6 +132,7 @@ It is recommended to look at examples [here](https://github.com/kebasyaty/ramifi
132
132
  ```python
133
133
  import re
134
134
  import asyncio
135
+ from typing import Any
135
136
  from datetime import datetime
136
137
  import pprint
137
138
 
@@ -187,25 +188,20 @@ class User:
187
188
  ignored=True,
188
189
  )
189
190
 
190
-
191
- # Optional method.
191
+ # Optional method
192
192
  async def add_validation(self) -> dict[str, str]:
193
193
  """Additional validation of fields."""
194
194
  gettext = translations.gettext
195
- error_map: dict[str, str] = {}
196
-
197
- # Get clean data.
198
- id = self.id.value
199
- username = self.username.value
200
- password = self.password.value
201
- сonfirm_password = self.сonfirm_password.value
195
+ cd, err_map = self.get_clean_data()
202
196
 
203
- if re.match(r"^[a-zA-Z0-9_]+$", username) is None:
204
- error_map["username"] = gettext("Allowed chars: %s") % "a-z A-Z 0-9 _"
197
+ # Check username
198
+ if re.match(r"^[a-zA-Z0-9_]+$", cd["username"]) is None:
199
+ err_map["username"] = gettext("Allowed chars: %s") % "a-z A-Z 0-9 _"
205
200
 
206
- if id is None and (password != сonfirm_password):
207
- error_map["password"] = gettext("Passwords do not match!")
208
- return error_map
201
+ # Check password
202
+ if cd["_id"] is None and (cd["password"] != cd["сonfirm_password"]):
203
+ err_map["password"] = gettext("Passwords do not match!")
204
+ return err_map
209
205
 
210
206
 
211
207
  async def main():
@@ -255,6 +251,9 @@ async def main():
255
251
  # (if necessary)
256
252
  # await User.collection().drop()
257
253
 
254
+ # Close connection.
255
+ await client.close()
256
+
258
257
 
259
258
  if __name__ == "__main__":
260
259
  asyncio.run(main())
@@ -45,9 +45,9 @@ ramifice/fields/general/number_group.py,sha256=jspiA9hWiU_hNhXbTku2rZG3UezrhEVBG
45
45
  ramifice/fields/general/text_group.py,sha256=hYVX4-ipD2_eyj-WpHIHnFrpQevySaVd4twffUsrOLo,1164
46
46
  ramifice/models/__init__.py,sha256=y5jRhSzcPuEVUWr1u--o1GyjFb7irlf5Rn2gPvQ3IPg,26
47
47
  ramifice/models/decorator.py,sha256=PX6b8DTP_Qz1SjyPcZ1vGDS4AGRZ6ZD8z8y6497j-DM,6685
48
- ramifice/models/model.py,sha256=m19E7h3Fv2F7oDotc1z_n_NglFN7KmXOrNL0r4Jg_y4,7352
48
+ ramifice/models/model.py,sha256=ufBWkAHvZjP3kN9x-VMPVq7k6vHhxcTvECV-BvaP6dc,7750
49
49
  ramifice/paladins/__init__.py,sha256=I2FzvCrp6upv_GPLfDqaVLwIT6-3Dp_K9i51tFUXDuc,673
50
- ramifice/paladins/check.py,sha256=mxvnHR9EG7eQrGOE7wph1lCUq3jf2RF0Ovhhtz7W3g8,6974
50
+ ramifice/paladins/check.py,sha256=L7mYsN5qp6ZlGiyPBQK1jw4GN03aIh8QpbbdK6-n6S4,6968
51
51
  ramifice/paladins/delete.py,sha256=Ynew5zvEBRJNmss5I8hSIp7KgBHpSvDEJCwOfMH5MUU,3723
52
52
  ramifice/paladins/password.py,sha256=hdEfSwz0a9FJ5IIYpyD9bmV_kNGvXP4OV5Ea-V0Yx98,3341
53
53
  ramifice/paladins/refrash.py,sha256=0qst0ii2ThH-VJduSI1zgkuZQGLnR8IiIu5rTVxzM9U,1254
@@ -74,11 +74,11 @@ ramifice/utils/tools.py,sha256=LZyA715HnkNO7TcBu4Ia29A6Ko3n-F2BRULzIyNKt9o,3279
74
74
  ramifice/utils/translations.py,sha256=Jh0nzwcn3bhUU2TjPAQboe3_pkVyhYQYdeINyC5SQo8,4701
75
75
  ramifice/utils/unit.py,sha256=ToBeu92tzOY32fuzLdxScNeYXvGIDr0nx7yTv2DShVo,2604
76
76
  ramifice/utils/mixins/__init__.py,sha256=fTsjH8h4OGvFC4zGawLLbU2i-c2OBdPftC3A-ZT5Pbw,379
77
- ramifice/utils/mixins/add_valid.py,sha256=vYq4wGdpfA4iLMts7G0NvDALZBwupOScsajDFWCmmYg,472
77
+ ramifice/utils/mixins/add_valid.py,sha256=00eIBlgsUU1TfDo1rUQT5zw7_Iv9IubORTbzuKoVB5o,425
78
78
  ramifice/utils/mixins/hooks.py,sha256=h8coNstWWHI4VwPgpjx0NWTj93-5NDAGtav0VFh-fk4,1031
79
79
  ramifice/utils/mixins/indexing.py,sha256=WVLxmkLKg-C_LHn2hq6LJuOkSr9eS-XUUvCMgK-pKYo,387
80
80
  ramifice/utils/mixins/json_converter.py,sha256=qBqFYol3Pbq1kX33EWB6FsYUL3AGSdYNtQE97HQ9jy4,1225
81
- ramifice-0.8.15.dist-info/METADATA,sha256=vQ7R_-JH-IBtlnJYLSNYMVM0jCmS25dLfvJNOrimQdM,20928
82
- ramifice-0.8.15.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
83
- ramifice-0.8.15.dist-info/licenses/LICENSE,sha256=LrEL0aTZx90HDwFUQCJutORiDjJL9AnuVvCtspXIqt4,1095
84
- ramifice-0.8.15.dist-info/RECORD,,
81
+ ramifice-0.8.17.dist-info/METADATA,sha256=gXiqJfKJX6s5dpHEir2eZeU82lhZPdUP9Osf74Ba6BI,20884
82
+ ramifice-0.8.17.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
83
+ ramifice-0.8.17.dist-info/licenses/LICENSE,sha256=LrEL0aTZx90HDwFUQCJutORiDjJL9AnuVvCtspXIqt4,1095
84
+ ramifice-0.8.17.dist-info/RECORD,,