Definition Selector
This module provides the DefinitionSelector class which is a Selector for the BaseDefinition object.
The DefinitionSelector class allows for querying and filtering of BaseDefinition objects based on various parameters such as event, key, and language. It is a subclass of the Select class.
- Classes:
DefinitionSelector: A selector model for the BaseDefinition object, it allows for querying and filtering of BaseDefinition objects.
- class loglan_core.addons.definition_selector.DefinitionSelector(model=<class 'loglan_core.definition.BaseDefinition'>, is_sqlite=False, case_sensitive=False, disable_model_check=False)[source]
Bases:
BaseSelectorThis class is a selector model for the BaseDefinition object. It allows for querying and filtering of BaseDefinition objects based on various parameters such as event, key, and language. It is a subclass of the Select class.
- inherit_cache()
Property that always returns True.
- Raises:
ValueError – If the provided class_ is not a subclass of BaseDefinition.
- model
The class to be used as the returned object.
- is_sqlite
Boolean specifying if the object is being used with SQLite or not.
- __init__(model=<class 'loglan_core.definition.BaseDefinition'>, is_sqlite=False, case_sensitive=False, disable_model_check=False)[source]
Initializes the DefinitionSelector object with the provided parameters.
- Parameters:
model (Type[BaseDefinition]) – The class to be used as the base key. Must be a subclass of BaseDefinition.
is_sqlite (bool) – If SQLite is being used. Defaults to False.
case_sensitive (bool) – If the queries should be case-sensitive.
disable_model_check (bool) – If the model check is disabled during initialization.
- Raises:
ValueError – If the provided model is not a subclass of BaseDefinition.
- by_event(event_id=None)[source]
This method filters the definitions by the given event id.
- Parameters:
event_id (int | None) – The id of the event to filter by. If None, no event filtering is applied.
- Returns:
The filtered DefinitionSelector instance.
- Return type:
- by_key(key, language=None, distinct=False)[source]
This method filters the definitions by the provided key, language and case sensitivity.
- Parameters:
key (BaseKey | str) – The key to filter by. Can be an instance of BaseKey or a string.
language (str | None) – The language to filter by.
None (If)
applied. (no language filtering is)
distinct (bool) – If True, only distinct keys will be returned.
- Returns:
The filtered DefinitionSelector instance with distinct keys.
- Return type:
Self