Options API Reference

Options Classes

class ldaporm.options.Options(meta)[source]

Bases: object

Options class for LDAP model metadata and configuration.

This class manages all the metadata for an LDAP model, including field mappings, LDAP server configuration, and model attributes. It provides Django-like model options interface for LDAP ORM models.

This gets instantiated by parsing the Meta class for the model, and is available as model._meta on the model class.

If you are subclassing another model, the Meta classes will be merged in MRO (Method Resolution Order) for the subclass. This means that the Meta class for the subclass will have all the options from the parent class, plus any options that are defined or overridden in the subclass.

Parameters:

meta – The Meta class from the model definition.

__init__(meta) None[source]
add_field(field: Field) None[source]

Used by the LdapModelBase` metaclass to add a field to the model.

Parameters:

field – The field to add.

contribute_to_class(cls: type['Model'], name: str) None[source]

Used by the LdapModelBase` metaclass to add this Options instance to a model class.

Parameters:
  • cls – The model class to contribute to.

  • name – The name of the options attribute.

get_field(field_name: str) Field[source]

Return a field instance given the name of a forward or reverse field.

Parameters:

field_name – The name of the field to retrieve.

Returns:

The field instance.

Raises:

FieldDoesNotExist – If no field with the given name exists.

get_fields(include_parents: bool = True, include_hidden: bool = False) list['Field'][source]

Get fields for this model. This is here to fool Django’s ModelForm.

Parameters:
  • include_parents – Whether to include parent fields (unused).

  • include_hidden – Whether to include hidden fields (unused).

Returns:

A list of all fields.

setup_pk(field: Field) None[source]

Used by the LdapModelBase` metaclass to set up the primary key field.

Parameters:

field – The field to check for primary key status.

attribute_to_field_name_map

Get a mapping of LDAP attribute names to field names. This is used by the LdapManager` to map LDAP attribute names to python field names for a model.

attributes

Get a list of LDAP attribute names for all fields. This is used by the LdapManager` to get the LDAP attribute names for a model.

attributes_map

Get a mapping of field names to LDAP attribute names. This is used by the LdapManager` to map LDAP attribute names to Field instances for a model.

base_manager: LdapManager | None

This is set up by the LdapModelBase`

basedn: str | None
property concrete_fields: list['Field']

Get concrete fields for this model (alias for fields).

This is here to fool Django’s ModelForm.

Returns:

A list of all fields.

concrete_model: Model | None

This is set up by the LdapModelBase`

default_permissions: tuple[str, ...]

The default permissions for this model. This is a tuple of the permissions that are applied to the model by default. This is here

extra_objectclasses: list[str]

Extra objectclasses to add to this model when we are creating new records

fields

Get all fields for this model.

fields_map

Get a mapping of field names to field instances. This is used by the LdapManager` to get the field instances for a model.

property label: str

Get the model label (object name).

Returns:

The model’s object name.

property label_lower: str

Get the lowercase model label.

Returns:

The lowercase model name.

ldap_options: list[str]

A list of options to pass to the LDAP server. The only current option is

ldap_server: str
local_fields: list[Field]

This is set up by the LdapModelBase`

local_many_to_many: list[Field]
manager_class: type[LdapManager]

The default manager class to use for this model. This is really only

many_to_many: list[Field]
meta

This is set up by the LdapModelBase`

model_name: str | None

This is set up by the LdapModelBase`

object_name: str | None

This is set up by the LdapModelBase`

objectclass: str | None

The objectclass for this model. This will be automatically added to any

ordering: list[str]

The default ordering for this model. This is a list of field names to order

password_attribute: str | None

The attribute to use for the password. This is used to store the password for the user. If this is not a user model, this will be

permissions: list[str]

The permissions for this model. This is a list of the permissions that are applied to the model. This is here really just to fool

pk: Field | None

This is set up by the LdapModelBase` metaclass. It is not intended to be set by the user. It will be

private_fields: list[Field]
userid_attribute: str

The attribute to use for the userid. This is used to identify the user when we are searching for them. If this is not a user model, this

verbose_name: str | None
verbose_name_plural: str | None
property verbose_name_raw: str

Return the untranslated verbose name.

Returns:

The untranslated verbose name.