GeneralManager 0.11.0__py3-none-any.whl → 0.11.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.
@@ -47,7 +47,7 @@ class DBBasedInterface(InterfaceBase, Generic[MODEL_TYPE]):
47
47
  ):
48
48
  """
49
49
  Initialize the interface and load the associated model instance by primary key.
50
-
50
+
51
51
  If a `search_date` is provided, retrieves the historical record as of that date; otherwise, loads the current record.
52
52
  """
53
53
  super().__init__(*args, **kwargs)
@@ -136,9 +136,9 @@ class DBBasedInterface(InterfaceBase, Generic[MODEL_TYPE]):
136
136
  def getAttributeTypes(cls) -> dict[str, AttributeTypedDict]:
137
137
  """
138
138
  Return a dictionary mapping each attribute name of the model to its type information and metadata.
139
-
139
+
140
140
  The returned dictionary includes all standard model fields, custom fields, foreign keys, many-to-many, and reverse relation fields, excluding any GenericForeignKey fields. For each attribute, the metadata specifies its Python type (translated from Django field types when possible), whether it is required, editable, derived, and its default value. For related models with a general manager class, the type is set to that class.
141
-
141
+
142
142
  Returns:
143
143
  dict[str, AttributeTypedDict]: Mapping of attribute names to their type information and metadata.
144
144
  """
@@ -248,12 +248,14 @@ class DBBasedInterface(InterfaceBase, Generic[MODEL_TYPE]):
248
248
  def getAttributes(cls) -> dict[str, Callable[[DBBasedInterface], Any]]:
249
249
  """
250
250
  Return a dictionary mapping attribute names to callables that retrieve values from a DBBasedInterface instance.
251
-
251
+
252
252
  The mapping includes accessors for custom fields, standard model fields, foreign keys, many-to-many relations, and reverse relations. For related models with a general manager class, the accessor returns an instance of that class; otherwise, it returns the related object or queryset. Raises a ValueError if a field name conflict is detected.
253
-
253
+
254
254
  Returns:
255
255
  dict: A dictionary where keys are attribute names and values are callables that extract the corresponding value from a DBBasedInterface instance.
256
256
  """
257
+ from general_manager.manager.generalManager import GeneralManager
258
+
257
259
  field_values: dict[str, Any] = {}
258
260
 
259
261
  field_name_list, to_ignore_list = cls.handleCustomFields(cls._model)
@@ -274,10 +276,14 @@ class DBBasedInterface(InterfaceBase, Generic[MODEL_TYPE]):
274
276
  related_model,
275
277
  "_general_manager_class",
276
278
  ):
277
- generalManagerClass = related_model._general_manager_class # type: ignore
279
+ generalManagerClass = cast(
280
+ Type[GeneralManager], related_model._general_manager_class
281
+ )
278
282
  field_values[f"{field_name}"] = (
279
- lambda self, field_name=field_name, manager_class=generalManagerClass: manager_class(
280
- getattr(self._instance, field_name).pk
283
+ lambda self, field_name=field_name, manager_class=generalManagerClass: (
284
+ manager_class(getattr(self._instance, field_name).pk)
285
+ if getattr(self._instance, field_name)
286
+ else None
281
287
  )
282
288
  )
283
289
  else:
@@ -339,10 +345,10 @@ class DBBasedInterface(InterfaceBase, Generic[MODEL_TYPE]):
339
345
  def _getCustomFields(model: Type[models.Model] | models.Model) -> list[str]:
340
346
  """
341
347
  Return a list of custom field names defined directly as class attributes on the given Django model.
342
-
348
+
343
349
  Parameters:
344
350
  model: The Django model class or instance to inspect.
345
-
351
+
346
352
  Returns:
347
353
  A list of field names for fields declared directly on the model class, excluding those defined via Django's meta system.
348
354
  """
@@ -356,7 +362,7 @@ class DBBasedInterface(InterfaceBase, Generic[MODEL_TYPE]):
356
362
  def __getModelFields(cls) -> list[str]:
357
363
  """
358
364
  Return a list of field names for the model that are neither many-to-many nor related fields.
359
-
365
+
360
366
  Fields representing many-to-many relationships or relations to other models are excluded from the result.
361
367
  """
362
368
  return [
@@ -380,7 +386,7 @@ class DBBasedInterface(InterfaceBase, Generic[MODEL_TYPE]):
380
386
  def __getManyToManyFields(cls) -> list[tuple[str, str]]:
381
387
  """
382
388
  Return a list of tuples representing all many-to-many fields on the model.
383
-
389
+
384
390
  Each tuple contains the field name twice. Fields that are generic foreign keys are excluded.
385
391
  """
386
392
  return [
@@ -393,7 +399,7 @@ class DBBasedInterface(InterfaceBase, Generic[MODEL_TYPE]):
393
399
  def __getReverseRelations(cls) -> list[tuple[str, str]]:
394
400
  """
395
401
  Return a list of reverse one-to-many relations for the model, excluding generic foreign keys.
396
-
402
+
397
403
  Each tuple contains the related field's name and its default related accessor name (e.g., `fieldname_set`).
398
404
  """
399
405
  return [
@@ -502,7 +508,7 @@ class DBBasedInterface(InterfaceBase, Generic[MODEL_TYPE]):
502
508
  def getFieldType(cls, field_name: str) -> type:
503
509
  """
504
510
  Return the type associated with a given model field name.
505
-
511
+
506
512
  If the field is a relation and its related model has a `_general_manager_class` attribute, that class is returned; otherwise, returns the Django field type.
507
513
  """
508
514
  field = cls._model._meta.get_field(field_name)
@@ -17,12 +17,12 @@ modelsModel = TypeVar("modelsModel", bound=models.Model)
17
17
  def getFullCleanMethode(model: Type[models.Model]) -> Callable[..., None]:
18
18
  """
19
19
  Return a custom `full_clean` method for a Django model that performs both standard validation and additional rule-based checks.
20
-
20
+
21
21
  The generated method first applies Django's built-in model validation, then evaluates custom rules defined in the model's `_meta.rules` attribute. If any validation or rule fails, it raises a `ValidationError` containing all collected errors.
22
-
22
+
23
23
  Parameters:
24
24
  model (Type[models.Model]): The Django model class for which to generate the custom `full_clean` method.
25
-
25
+
26
26
  Returns:
27
27
  Callable[..., None]: A `full_clean` method that can be assigned to the model class.
28
28
  """
@@ -30,7 +30,7 @@ def getFullCleanMethode(model: Type[models.Model]) -> Callable[..., None]:
30
30
  def full_clean(self: models.Model, *args: Any, **kwargs: Any):
31
31
  """
32
32
  Performs full validation on the model instance, including both standard Django validation and custom rule-based checks.
33
-
33
+
34
34
  Aggregates errors from Django's built-in validation and any additional rules defined in the model's `_meta.rules` attribute. Raises a `ValidationError` containing all collected errors if any validation or rule check fails.
35
35
  """
36
36
  errors: dict[str, Any] = {}
@@ -41,7 +41,7 @@ def getFullCleanMethode(model: Type[models.Model]) -> Callable[..., None]:
41
41
 
42
42
  rules: list[Rule] = getattr(self._meta, "rules")
43
43
  for rule in rules:
44
- if not rule.evaluate(self):
44
+ if rule.evaluate(self) is False:
45
45
  error_message = rule.getErrorMessage()
46
46
  if error_message:
47
47
  errors.update(error_message)
@@ -78,7 +78,7 @@ class GeneralManagerModel(GeneralManagerBasisModel):
78
78
  def _history_user(self, value: AbstractUser) -> None:
79
79
  """
80
80
  Set the user responsible for the most recent change to the model instance.
81
-
81
+
82
82
  Parameters:
83
83
  value (AbstractUser): The user to associate with the latest modification.
84
84
  """
@@ -58,6 +58,19 @@ class GeneralManager(metaclass=GeneralManagerMeta):
58
58
  else:
59
59
  raise TypeError(f"Unsupported type for union: {type(other)}")
60
60
 
61
+ def __eq__(
62
+ self,
63
+ other: object,
64
+ ) -> bool:
65
+ """
66
+ Check equality based on the identification dictionary.
67
+
68
+ Returns True if the other object is a GeneralManager with the same identification, otherwise False.
69
+ """
70
+ if not isinstance(other, GeneralManager):
71
+ return False
72
+ return self.identification == other.identification
73
+
61
74
  @property
62
75
  def identification(self):
63
76
  return self.__id
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: GeneralManager
3
- Version: 0.11.0
3
+ Version: 0.11.2
4
4
  Summary: Modular Django-based data management framework with ORM, GraphQL, fine-grained permissions, rule validation, calculations and caching.
5
5
  Author-email: Tim Kleindick <tkleindick@yahoo.de>
6
6
  License-Expression: MIT
@@ -19,12 +19,12 @@ general_manager/factory/factoryMethods.py,sha256=9Bag891j0XHe3dUBAFi7gUKcKeUwcBZ
19
19
  general_manager/interface/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
20
  general_manager/interface/baseInterface.py,sha256=cFsDU-nhj_O6Gir3eO0ukGKNn9Pplhe6gEMccHNi4O0,8648
21
21
  general_manager/interface/calculationInterface.py,sha256=fTD3WQpsn3ImaxGW5S-JwVJyJJPoPp2mR6lAambdB8U,4755
22
- general_manager/interface/databaseBasedInterface.py,sha256=_E4HoHmU8A_5_voSpeGp8AkiWbHGF3ZY1zO9phIezh8,21647
22
+ general_manager/interface/databaseBasedInterface.py,sha256=F-a6P9rvPUmlcoZw1rKSWEAzbYGccQRL6uokv6C46qo,21782
23
23
  general_manager/interface/databaseInterface.py,sha256=rhKVXhg0ztdIxKikTWtgjrkA7cwZTOYlEsRh0RWajDQ,6732
24
- general_manager/interface/models.py,sha256=gGYW5f1AUBpBakV3O0qsZwqMiWxZGdKRYXWaCBjt1oI,3334
24
+ general_manager/interface/models.py,sha256=P4bYb-Q7-moZR-hgIqwruMuftDgUW6FSqjPtWfHW04o,3311
25
25
  general_manager/interface/readOnlyInterface.py,sha256=TkfbOeaa2wCq5kCv0a3IwJWcYOTVbtNsdNWmGAz0Mns,11217
26
26
  general_manager/manager/__init__.py,sha256=l3RYp62aEhj3Y975_XUTIzo35LUnkTJHkb_hgChnXXI,111
27
- general_manager/manager/generalManager.py,sha256=24eRdJW8BYPchYySxFNMywwk9LOhrab5Y4QiQWXZWT8,8730
27
+ general_manager/manager/generalManager.py,sha256=4Qn9TYpZpqh5qC95BEAQhpiZgDrRXrAJjO2BbbXUdNg,9129
28
28
  general_manager/manager/groupManager.py,sha256=8dpZUfm7aFL4lraUWv4qbbDRClQZaYxw4prclhBZYZs,4367
29
29
  general_manager/manager/input.py,sha256=-pJXGJ-g2-OxZfl4Buj3mQkf05fN4p8MsR2Lh9BQcEo,3208
30
30
  general_manager/manager/meta.py,sha256=-9celpo-oZmkTb8TnHfvcd_4XWTy1cn2UO-jp13NFmQ,6387
@@ -51,8 +51,8 @@ general_manager/utils/makeCacheKey.py,sha256=UlFsxHXgsYy69AAelkF6GDvY4h7AImT2bBn
51
51
  general_manager/utils/noneToZero.py,sha256=KfQtMQnrT6vsYST0K7lv6pVujkDcK3XL8czHYOhgqKQ,539
52
52
  general_manager/utils/pathMapping.py,sha256=nrz5owQg2a69Yig1eCXorR9U0NSw7NmBAk5OkeoHTdA,6842
53
53
  general_manager/utils/testing.py,sha256=ElZ8p4iZHxsHjDN8Lm5TmI6527CW747ltDOmtY6gAhk,11872
54
- generalmanager-0.11.0.dist-info/licenses/LICENSE,sha256=YGFm0ieb4KpkMRRt2qnWue6uFh0cUMtobwEBkHwajhc,1450
55
- generalmanager-0.11.0.dist-info/METADATA,sha256=pMD3IcrqWIx1zEQIsMr2y1gS1nZjP8maVN29k8XSpqA,6206
56
- generalmanager-0.11.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
57
- generalmanager-0.11.0.dist-info/top_level.txt,sha256=sTDtExP9ga-YP3h3h42yivUY-A2Q23C2nw6LNKOho4I,16
58
- generalmanager-0.11.0.dist-info/RECORD,,
54
+ generalmanager-0.11.2.dist-info/licenses/LICENSE,sha256=YGFm0ieb4KpkMRRt2qnWue6uFh0cUMtobwEBkHwajhc,1450
55
+ generalmanager-0.11.2.dist-info/METADATA,sha256=zj1UfC74gZUgz9inrRIBqx2FAw0_UlXdxt_Iu-mvCyE,6206
56
+ generalmanager-0.11.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
57
+ generalmanager-0.11.2.dist-info/top_level.txt,sha256=sTDtExP9ga-YP3h3h42yivUY-A2Q23C2nw6LNKOho4I,16
58
+ generalmanager-0.11.2.dist-info/RECORD,,