server.resources package¶
This package handles various dynamic data that is stored in memory. The data mainly constitutes of entity objects that are emitted by devices and need to be forwarded to clients.
- each entity
is a JSON object (dict) conforming one of the JSON Schemas
has a unique ID as one of its properties
- apart from text/number/bool values, it may also contain arrays with
ID references to other entities (see device.json)
- all entities of the same type are grouped together in a single dict
the keys are their IDs
this grouped representation is then synchronized to clients
Note that in some cases the device emits a slightly different object that is then tranformed by the server to the actual entity, which conforms the schema.
Other non-entity dynamic resources include:
mapping of device socketio connection
mapping of client (user) socketio connection
management of temporary directories (temporary storage for datafiles)
Submodules¶
server.resources.resources module¶
- class server.resources.resources.EntityContainer(validator_new, validator_update)[source]¶
Bases:
objectContainer for entity objects (JSON compatible). Each entity has to contain ‘id’ field with a unique id of type str.
- class server.resources.resources.ParentEntityContainer(validator_new, validator_update, children={})[source]¶
Bases:
EntityContainerEntity container with lists of id references to its children. When an entity is added or removed from the child-container, the list of references in the appropriate parent-entity is updated.
- class server.resources.resources.SocketioConnections(multiple_connections=False)[source]¶
Bases:
objectTrack active socket.io connections. Each account (user or device) is allowed only 1 active connection. This structure can be used to
query id_public (account) by sid (connection)
and vice versa - query sid by id_public
Modification of added entries are not allowed (only add, get, remove) and unique constraint is enforced on both sid and id_public to prevent errors.
- property by_pubid¶
Public id of account -> sid of connection.
- property by_sid¶
Sid of connection -> public id of account.
- class server.resources.resources.TempdirManager[source]¶
Bases:
object- add(dir_id)[source]¶
Create a new temporary directory for given id (e.g. device_id). Id must be unique otherwise UniqueIdConflict is raised.