teos.users_dbm¶
-
class
UsersDBM(db_path)[source]¶ Bases:
common.db_manager.DBManagerThe
UsersDBMis in charge of interacting with the users database (LevelDB). Keys and values are stored as bytes in the database but processed as strings by the manager.- Parameters
db_path (
str) – the path (relative or absolute) to the system folder containing the database. A fresh database will be created if the specified path does not contain one.- Raises
ValueError – If the provided
db_pathis not a string.plyvel.Error – If the db is currently unavailable (being used by another process).
-
logger¶ The logger for this component.
- Type
Logger
-
delete_user(user_id)[source]¶ Deletes a user record from the database.
- Parameters
user_id (
str) – a 33-byte hex-encoded string identifying the user.- Returns
True if the user was deleted from the database or it was non-existent, False otherwise.
- Return type
bool
-
load_all_users()[source]¶ Loads all user records from the database.
- Returns
A dictionary containing all users indexed by
user_pk.Returns an empty dictionary if no data is found.
- Return type
dict
-
load_user(user_id)[source]¶ Loads a user record from the database using the
user_pkas identifier.- Parameters
user_id (
str) – a 33-byte hex-encoded string identifying the user.- Returns
A dictionary containing the user data if the
keyis found.Returns
Noneotherwise.- Return type
dict
-
store_user(user_id, user_data)[source]¶ Stores a user record to the database.
user_pkis used as identifier.- Parameters
user_id (
str) – a 33-byte hex-encoded string identifying the user.user_data (
dict) – the user associated data, as a dictionary.
- Returns
True if the user was stored in the database, False otherwise.
- Return type
bool