tldap.database package

Submodules

tldap.database.helpers module

Various helper functions to aid applications processing schema specific functions.

tldap.database.helpers.add_group_member(changes: Changeset, member: LdapObject) Changeset[source]
tldap.database.helpers.get_fields_account() Dict[str, Field][source]
tldap.database.helpers.get_fields_common() Dict[str, Field][source]
tldap.database.helpers.get_fields_group() Dict[str, Field][source]
tldap.database.helpers.get_fields_password_object() Dict[str, Field][source]
tldap.database.helpers.get_fields_person() Dict[str, Field][source]
tldap.database.helpers.get_fields_pwdpolicy() Dict[str, Field][source]
tldap.database.helpers.get_fields_shadow() Dict[str, Field][source]
tldap.database.helpers.get_fields_shibboleth() Dict[str, Field][source]
tldap.database.helpers.load_account(python_data: LdapObject, group_table: Type[LdapObject]) LdapObject[source]
tldap.database.helpers.load_group(python_data: LdapObject, account_table: Type[LdapObject]) LdapObject[source]
tldap.database.helpers.load_password_object(python_data: LdapObject) LdapObject[source]
tldap.database.helpers.load_person(python_data: LdapObject, group_table: Type[LdapObject]) LdapObject[source]
tldap.database.helpers.load_pwdpolicy(python_data: LdapObject) LdapObject[source]
tldap.database.helpers.load_shadow(python_data: LdapObject) LdapObject[source]
tldap.database.helpers.load_shibboleth(python_data: LdapObject) LdapObject[source]
tldap.database.helpers.rdn_to_dn(changes: Changeset, name: str, base_dn: str) Changeset[source]

Convert the rdn to a fully qualified DN for the specified LDAP connection.

Parameters:
  • changes – The changes object to lookup.

  • name – rdn to convert.

  • base_dn – The base_dn to lookup.

Returns:

fully qualified DN.

tldap.database.helpers.remove_group_member(changes: Changeset, member: LdapObject) Changeset[source]
tldap.database.helpers.save_account(changes: Changeset, database: Database, format_fields: Set[str] | None = None) Changeset[source]
tldap.database.helpers.save_group(changes: Changeset) Changeset[source]
tldap.database.helpers.save_password_object(changes: Changeset) Changeset[source]
tldap.database.helpers.save_person(changes: Changeset, database: Database, format_fields: Set[str] | None = None) Changeset[source]
tldap.database.helpers.save_pwdpolicy(changes: Changeset) Changeset[source]
tldap.database.helpers.save_shadow(changes: Changeset) Changeset[source]
tldap.database.helpers.save_shibboleth(changes: Changeset, database: Database) Changeset[source]
tldap.database.helpers.set_object_class(changes: Changeset, object_class: List[str]) Changeset[source]

Module contents

High level database interaction.

class tldap.database.Changeset(fields: Dict[str, Field], src: LdapObject, d: dict | None = None)[source]

Bases: ImmutableDict

Represents a set of changes to an LdapObject.

property changes: Dict[str, List[Tuple[MODIFY_ADD, List[Any]]]]
property errors: List[str]
force_add(key: str, value: Any) Changeset[source]
force_delete(key: str, value: Any) Changeset[source]
force_replace(key: str, value: Any) Changeset[source]
get_value_as_list(key: str) List[Any][source]
get_value_as_single(key: str) any[source]
property is_valid: bool
property src: LdapObject
class tldap.database.Database(connection: LdapBase, settings: dict | None = None)[source]

Bases: object

property connection: LdapBase
property settings: dict
class tldap.database.LdapObject(d: dict | None = None)[source]

Bases: ImmutableDict

A high level python representation of a LDAP object.

get_as_list(key: str) List[Any][source]
get_as_single(key: str) Any[source]
classmethod get_fields() Dict[str, Field][source]
classmethod get_search_options(database: Database) SearchOptions[source]
classmethod on_load(python_data: LdapObject, database: Database) LdapObject[source]
classmethod on_save(changes: Changeset, database: Database) Changeset[source]
class tldap.database.NotLoaded[source]

Bases: object

Base class to represent a related field that has not been loaded.

load(database: Database | None = None) LdapObject[source]
class tldap.database.NotLoadedList(*, table: Type[LdapObject], key: str, value: str)[source]

Bases: NotLoaded

Represents a list of objects that needs to be loaded via a single key.

load(database: Database | None = None) List[LdapObject][source]
class tldap.database.NotLoadedObject(*, table: Type[LdapObject], key: str, value: str)[source]

Bases: NotLoaded

Represents a single object that needs to be loaded.

load(database: Database | None = None) LdapObject[source]
class tldap.database.SearchOptions(base_dn: str, object_class: Set[str], pk_field: str)[source]

Bases: object

Application specific search options.

tldap.database.changeset(python_data: LdapObject, d: dict) Changeset[source]

Generate changes object for ldap object.

tldap.database.delete(python_data: LdapObject, database: Database | None = None) None[source]

Delete a LdapObject from the database.

tldap.database.get_database(database: Database | None) Database[source]
tldap.database.get_default_database()[source]
tldap.database.get_one(table: Type[LdapObject], query: Q | None = None, database: Database | None = None, base_dn: str | None = None) LdapObject[source]

Get exactly one result from the database or fail.

tldap.database.insert(python_data: LdapObject, database: Database | None = None) LdapObject[source]

Insert a new python_data object in the database.

tldap.database.preload(python_data: LdapObject, database: Database | None = None) LdapObject[source]

Preload all NotLoaded fields in LdapObject.

tldap.database.rename(python_data: LdapObject, new_base_dn: str | None = None, database: Database | None = None, **kwargs) LdapObject[source]

Move/rename a LdapObject in the database.

tldap.database.save(changes: Changeset, database: Database | None = None) LdapObject[source]

Save all changes in a LdapChanges.

tldap.database.search(table: Type[LdapObject], query: Q | None = None, database: Database | None = None, base_dn: str | None = None) Iterator[LdapObject][source]

Search for a object of given type in the database.