search.utils
Attributes
Classes
Abstract base class for generic types. |
|
Detects languages with the help of lingua-language-detector. |
Functions
|
|
|
This does the same thing as unidecode, except it special-cases |
Searches through the given SQLAlchemy base and returns the classes |
|
|
Filter out models that are polymorphic subclasses of other |
Given a query and the corresponding model add a filter |
|
|
Module Contents
- search.utils.normalize_text(text: str) str [source]
This does the same thing as unidecode, except it special-cases umlaut translation for German text.
- search.utils.searchable_sqlalchemy_models(base: type[T]) collections.abc.Iterator[type[onegov.search.Searchable]] [source]
Searches through the given SQLAlchemy base and returns the classes of all SQLAlchemy models found which inherit from the
onegov.search.mixins.Searchable
interface.
- search.utils.get_polymorphic_base(model: type[onegov.search.mixins.Searchable]) type[onegov.core.orm.Base | onegov.search.mixins.Searchable] [source]
Filter out models that are polymorphic subclasses of other models in order to save on queries.
- search.utils.apply_searchable_polymorphic_filter(query: sqlalchemy.orm.Query[T], model: Any) sqlalchemy.orm.Query[T] [source]
Given a query and the corresponding model add a filter that excludes any polymorphic variants, that are not searchable.
- class search.utils.classproperty(f: collections.abc.Callable[[type[Any]], T_co])[source]
Bases:
Generic
[T_co
]Abstract base class for generic types.
A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as:
class Mapping(Generic[KT, VT]): def __getitem__(self, key: KT) -> VT: ... # Etc.
This class can then be used as follows:
def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT: try: return mapping[key] except KeyError: return default