people.collections.people

Attributes

PersonT

Classes

BasePersonCollection

Abstract base class for generic types.

PersonCollection

Manages a list of people.

Module Contents

people.collections.people.PersonT[source]
class people.collections.people.BasePersonCollection(session: sqlalchemy.orm.Session, **kwargs: Any)[source]

Bases: onegov.core.collection.GenericCollection[PersonT]

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
property model_class: type[PersonT][source]
Abstractmethod:

add(first_name: str, last_name: str, **optional: Any) PersonT[source]
add_or_get(first_name: str, last_name: str, compare_names_only: bool = False, **optional: Any) PersonT[source]

Adds a person if it does not exist yet, otherwise returns the existing.

by_id(id: uuid.UUID) PersonT | None[source]
class people.collections.people.PersonCollection(session: sqlalchemy.orm.Session, **kwargs: Any)[source]

Bases: BasePersonCollection[onegov.people.models.Person]

Manages a list of people.

Use it like this:

from onegov.people import PersonCollection
people = PersonCollection(session)
property model_class: type[onegov.people.models.Person][source]
people_by_organisation(org: str | None, sub_org: str | None) list[onegov.people.models.Person][source]

Returns all persons of a given organisation and sub-organisation.

If organisation and sub-organisation are both None, all persons are returned.

unique_organisations() tuple[str | None, Ellipsis][source]
unique_sub_organisations(of_org: str | None = None) tuple[str | None, Ellipsis][source]