repository_orm.model
¶
Store the common business model of all entities.
Entity
¶
Bases: BaseModel
Model of any object no defined by it's attributes whom instead has an identity.
Unlike value objects, they have identity equality. We can change their values, and they are still recognizably the same thing.
An entity with a negative id means that the id needs to be set by the repository.
The _defined_values are used to know which attributes were set by the user at the time of merging objects.
Source code in repository_orm/model.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
|
__gt__(other)
¶
Assert if an object is greater than us.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other |
Entity
|
Entity to compare. |
required |
Source code in repository_orm/model.py
46 47 48 49 50 51 52 53 54 |
|
__hash__()
¶
Create an unique hash of the class object.
Source code in repository_orm/model.py
56 57 58 |
|
__init__(**data)
¶
Initialize the defined values.
Source code in repository_orm/model.py
31 32 33 34 |
|
__lt__(other)
¶
Assert if an object is smaller than us.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other |
Entity
|
Entity to compare. |
required |
Source code in repository_orm/model.py
36 37 38 39 40 41 42 43 44 |
|
__setattr__(attribute, value)
¶
Store the set attribute into the _defined_values.
Source code in repository_orm/model.py
61 62 63 64 65 |
|
clear_defined_values()
¶
Remove all references to defined values.
I tried to return self so that it can be used chained with repo.get(), but I get
a mypy error Incompatible return value type (got "Entity", expected "Entity")
Source code in repository_orm/model.py
103 104 105 106 107 108 109 |
|
defined_values()
property
¶
Return the entity defined values.
Source code in repository_orm/model.py
98 99 100 101 |
|
merge(other)
¶
Update the attributes with the ones manually set by the user of other.
If the other object has default values not set by the user, they won't be
propagated to self
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other |
Entity
|
Entity to compare. |
required |
Source code in repository_orm/model.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
|
model_name()
property
¶
Return the entity model name.
Source code in repository_orm/model.py
67 68 69 70 |
|
File
¶
Bases: Entity
, Generic[AnyStr]
Model a computer file.
Source code in repository_orm/model.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
|
basename()
property
¶
Return the name of the file.
Source code in repository_orm/model.py
137 138 139 140 |
|
content()
property
¶
Return the content of the file.
Returns:
Type | Description |
---|---|
AnyStr
|
The content of the file. |
Raises:
Type | Description |
---|---|
FileContentNotLoadedError
|
if the content is not yet loaded. |
Source code in repository_orm/model.py
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
|
dirname()
property
¶
Return the name of the file.
Source code in repository_orm/model.py
142 143 144 145 |
|
extension()
property
¶
Return the name of the file.
Source code in repository_orm/model.py
147 148 149 150 |
|