hololinked.core.interfaces.configuration.BaseConfigurationRepository
Repository/Persistence for a Thing instance that can be used for storing configuration.
Model your device setting's as properties and set db_persist=True/db_commit=True in the property's argument
to activate persistance. If your server dies and restarts, the settings will be reloaded and applied to your device.
Different storage backends (like JSON file, SQLAlchemy, MongoDB) are supported and custom backends can be implemented by inheriting from this class.
Source code in repo/hololinked/hololinked/core/interfaces/configuration.py
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 110 111 112 113 114 115 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 | |
Attributes
Functions
__init__
from_thing
classmethod
Build the repository for a Thing from the keyword arguments the Thing was created with.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Thing
|
the |
required |
|
Any
|
the keyword arguments given to the |
{}
|
Returns:
| Type | Description |
|---|---|
Self
|
the repository, ready to be used as the |
Source code in repo/hololinked/hololinked/core/interfaces/configuration.py
fetch_own_info
Fetch Thing instance's own information (some useful metadata which could help the Thing run).
get_property
Fetch a single property from the configuration storage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str | Property
|
string name or descriptor object |
required |
|
bool
|
deserialize the property if True |
True
|
Returns:
| Type | Description |
|---|---|
Any
|
property value |
Source code in repo/hololinked/hololinked/core/interfaces/configuration.py
get_properties
Get multiple properties at once from the configuration storage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
dict[str | Property, Any]
|
string names or the descriptor of the properties as a list |
required |
|
bool
|
deserialize the properties if True |
True
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
property names and values as items |
Source code in repo/hololinked/hololinked/core/interfaces/configuration.py
get_all_properties
Get all properties of the Thing instance from the configuration storage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
bool
|
deserialize the properties if True |
True
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
property names and values as items |
Source code in repo/hololinked/hololinked/core/interfaces/configuration.py
set_property
Change the value of an already existing property in the configuration storage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str | Property
|
string name or descriptor object |
required |
|
Any
|
value of the property |
required |
Source code in repo/hololinked/hololinked/core/interfaces/configuration.py
set_properties
Change the values of already existing properties in the configuration storage (at once).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
dict[str | Property, Any]
|
string names or the descriptor of the properties and their values. |
required |
Source code in repo/hololinked/hololinked/core/interfaces/configuration.py
create_missing_properties
create_missing_properties(properties: dict[str, Property], get_missing_property_names: bool = False) -> None | list[str]
Create any and all missing properties of Thing instance in the configuration storage.
Auto-invoked at Thing.__init__() and takes effect if new properties are introduced.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
dict[str, Property]
|
descriptors of the properties |
required |
|
bool
|
whether to return the list of missing property names |
False
|
Returns:
| Type | Description |
|---|---|
List[str]
|
list of missing properties if get_missing_property_names is True |
Source code in repo/hololinked/hololinked/core/interfaces/configuration.py
create_init_properties
Create properties that are supposed to be initialized from configuration storage.
Invoke this method once before running the thing instance to store their initial values.
The Thing instance is not accepted as an argument as the method would be used outside its lifecycle.
ID, class name and initial property names and valeus must match.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
ID of the thing instance to which these properties belong |
required |
|
str
|
Class name of the thing instance to which these properties belong (must be thing.class.name) |
required |
|
Any
|
property names and their initial values as dictionary pairs |
{}
|