directory.collections.directory_entry

Classes

DirectorySearchWidget

Base class for protocol classes.

DirectoryEntryCollection

Provides a view on a directory's entries.

Module Contents

class directory.collections.directory_entry.DirectorySearchWidget[DirectoryEntryT: onegov.directory.models.DirectoryEntry][source]

Bases: Protocol

Base class for protocol classes.

Protocol classes are defined as:

class Proto(Protocol):
    def meth(self) -> int:
        ...

Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing).

For example:

class C:
    def meth(self) -> int:
        return 0

def func(x: Proto) -> int:
    return x.meth()

func(C())  # Passes static type check

See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as:

class GenProto[T](Protocol):
    def meth(self) -> T:
        ...
property name: str[source]
property search_query: sqlalchemy.orm.Query[DirectoryEntryT][source]
adapt(query: sqlalchemy.orm.Query[DirectoryEntryT]) sqlalchemy.orm.Query[DirectoryEntryT][source]
html(layout: Any) markupsafe.Markup[source]
class directory.collections.directory_entry.DirectoryEntryCollection[DirectoryEntryT: onegov.directory.models.DirectoryEntry](directory: onegov.directory.models.Directory, type: Literal['*', 'generic'] = '*', keywords: collections.abc.Mapping[str, list[str]] | None = None, page: int = 0, search_widget: DirectorySearchWidget[DirectoryEntryT] | None = None)[source]
class directory.collections.directory_entry.DirectoryEntryCollection(directory: onegov.directory.models.Directory, type: str, keywords: collections.abc.Mapping[str, list[str]] | None = None, page: int = 0, search_widget: DirectorySearchWidget[DirectoryEntryT] | None = None)

Bases: onegov.core.collection.GenericCollection[DirectoryEntryT], onegov.core.collection.Pagination[DirectoryEntryT]

Provides a view on a directory’s entries.

The directory itself might be a natural place for lots of these methods to reside, but ultimately we want to avoid mixing the concerns of the directory model and this view-supporting collection.

type = '*'[source]
directory[source]
keywords[source]
page = 0[source]
search_widget = None[source]
__eq__(other: object) bool[source]

Returns True if the current and the other Pagination instance are equal. Used to find the current page in a list of pages.

subset() sqlalchemy.orm.Query[DirectoryEntryT][source]

Returns an SQLAlchemy query containing all records that should be considered for pagination.

property search: str | None[source]
property search_query: sqlalchemy.orm.Query[DirectoryEntryT] | None[source]
property page_index: int[source]

Returns the current page index (starting at 0).

page_by_index(index: int) Self[source]

Returns the page at the given index. A page here means an instance of the class inheriting from the Pagination base class.

by_name(name: str) DirectoryEntryT | None[source]
query() sqlalchemy.orm.Query[DirectoryEntryT][source]
valid_keywords[T](parameters: collections.abc.Mapping[str, T]) dict[str, T][source]
property directory_name: str[source]
property model_class: type[DirectoryEntryT][source]
available_filters(sort_choices: bool = False, sortfunc: collections.abc.Callable[[str], _typeshed.SupportsRichComparison] | None = None) collections.abc.Iterable[tuple[str, str, list[str]]][source]

Retrieve the filters with their choices.

By default the choices are returned in the same order as defined in the structrue. To filter alphabetically, set sort_choices=True.

for_keywords(singular: bool = False, **keywords: list[str]) Self[source]
for_toggled_keyword_value(keyword: str, value: str, singular: bool = False) Self[source]
without_keywords() Self[source]