slidge.util.db
#
This module covers a backend for storing user data persistently and managing a pseudo-roster for the gateway component.
Module Contents#
Classes#
Shelf implementation using the "dbm" generic dbm interface. |
|
A dataclass representing a gateway user |
|
Basic user store implementation using shelve from the python standard library |
|
A pseudo-set which always test True for membership |
|
A pseudo-roster for the gateway component. |
Attributes#
- class slidge.util.db.EncryptedShelf(filename, key, flag='c', protocol=None, writeback=False)[source]#
Bases:
shelve.DbfilenameShelf
Shelf implementation using the “dbm” generic dbm interface.
This is initialized with the filename for the dbm database. See the module’s __doc__ string for an overview of the interface.
- Parameters:
filename (os.PathLike) –
key (str) –
- class slidge.util.db.GatewayUser[source]#
A dataclass representing a gateway user
- registration_date: datetime.datetime | None[source]#
- class slidge.util.db.UserStore[source]#
Basic user store implementation using shelve from the python standard library
Set_file must be called before it is usable
- set_file(filename, secret_key=None)[source]#
Set the file to use to store user data
- Parameters:
filename (os.PathLike) – Path to the shelf file
secret_key (Optional[str]) – Secret key to store files encrypted on disk
- get_all()[source]#
Get all users in the store
- Returns:
An iterable of GatewayUsers
- Return type:
Iterable[GatewayUser]
- add(jid, registration_form)[source]#
Add a user to the store.
NB: there is no reason to call this manually, as this should be covered by slixmpp XEP-0077 and XEP-0100 plugins
- commit(user)[source]#
- Parameters:
user (GatewayUser) –
- get(_gateway_jid, _node, ifrom, iq)[source]#
Get a user from the store
NB: there is no reason to call this, it is used by SliXMPP internal API
- Parameters:
_gateway_jid –
_node –
ifrom (slixmpp.JID) –
iq –
- Returns:
- Return type:
Optional[GatewayUser]
- remove(_gateway_jid, _node, ifrom, _iq)[source]#
Remove a user from the store
NB: there is no reason to call this, it is used by SliXMPP internal API
- Parameters:
ifrom (slixmpp.JID) –
- get_by_jid(jid)[source]#
Convenience function to get a user from their JID.
- Parameters:
jid (slixmpp.JID) – JID of the gateway user
- Returns:
- Return type:
Optional[GatewayUser]
- get_by_stanza(s)[source]#
Convenience function to get a user from a stanza they sent.
- Parameters:
s (Union[slixmpp.Presence, slixmpp.Message, slixmpp.Iq]) – A stanza sent by the gateway user
- Returns:
- Return type:
Optional[GatewayUser]
- class slidge.util.db.YesSet[source]#
Bases:
set
A pseudo-set which always test True for membership
Initialize self. See help(type(self)) for accurate signature.