Options API Reference
Options Classes
- class ldaporm.options.Options(meta)[source]
Bases:
objectOptions 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
Metaclass for the model, and is available asmodel._metaon the model class.If you are subclassing another model, the
Metaclasses will be merged in MRO (Method Resolution Order) for the subclass. This means that theMetaclass 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.
- 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 thisOptionsinstance 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 toFieldinstances for a model.
- base_manager: LdapManager | None
This is set up by the
LdapModelBase`
- 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.
- 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.
- manager_class: type[LdapManager]
The default manager class to use for this model. This is really only
- meta
This is set up by the
LdapModelBase`
- 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