Models¶
Base models for dirty_models.
-
class
dirty_models.models.
BaseModel
(data=None, flat=False, *args, **kwargs)[source]¶ Bases:
dirty_models.base.BaseData
Base model with dirty feature. It stores original data and saves modifications in other side.
-
delete_attr_by_path
(field_path)[source]¶ It deletes fields looked up by field path. Field path is dot-formatted string path:
parent_field.child_field
.Parameters: field_path (str) – field path. It allows *
as wildcard.
-
export_deleted_fields
()[source]¶ Resturns a list with any deleted fields form original data. In tree models, deleted fields on children will be appended.
-
get_1st_attr_by_path
(field_path, **kwargs)[source]¶ It returns first value looked up by field path. Field path is dot-formatted string path:
parent_field.child_field
.Parameters: - field_path (str) – field path. It allows
*
as wildcard. - default – Default value if field does not exist.
If it is not defined
AttributeError
exception will be raised.
Returns: value
- field_path (str) – field path. It allows
-
get_attrs_by_path
(field_path, stop_first=False)[source]¶ It returns list of values looked up by field path. Field path is dot-formatted string path:
parent_field.child_field
.Parameters: - field_path (list or None.) – field path. It allows
*
as wildcard. - stop_first (bool) – Stop iteration on first value looked up. Default: False.
Returns: A list of values or None it was a invalid path.
Return type: list
orNone
- field_path (list or None.) – field path. It allows
-
-
class
dirty_models.models.
DynamicModel
(*args, **kwargs)[source]¶ Bases:
dirty_models.models.BaseDynamicModel
DynamicModel allow to create model with no structure. Each instance has its own derivated class from DynamicModels.
-
class
dirty_models.models.
FastDynamicModel
(*args, **kwargs)[source]¶ Bases:
dirty_models.models.BaseDynamicModel
FastDynamicModel allow to create model with no structure.
-
class
dirty_models.models.
HashMapModel
(*args, **kwargs)[source]¶ Bases:
dirty_models.base.InnerFieldTypeMixin
,dirty_models.models.BaseModel
Hash map model with dirty feature. It stores original data and saves modifications in other side.