Work Groups

PSF work groups and special interest groups.

Module Contents

Work Groups domain.

class WorkGroup[source]

Bases: AuditBase, SlugMixin

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

active: Mapped[bool]
created_at: Mapped[datetime.datetime]

Date/time of instance creation.

creator_id: Mapped[UUID]
id: Mapped[UUID]

UUID Primary key column.

name: Mapped[str]
purpose: Mapped[str]
slug: Mapped[str]
updated_at: Mapped[datetime.datetime]

Date/time of instance last update.

url: Mapped[str | None]
class WorkGroupController[source]

Bases: Controller

Controller for WorkGroup CRUD operations.

after_request: AfterRequestHookHandler | None

A sync or async function executed before a Request is passed to any route handler.

If this function returns a value, the request will not reach the route handler, and instead this value will be used.

after_response: AfterResponseHookHandler | None

A sync or async function called after the response has been awaited.

It receives the Request instance and should not return any values.

before_request: BeforeRequestHookHandler | None

A sync or async function called immediately before calling the route handler.

It receives the Request instance and any non-None return value is used for the response, bypassing the route handler.

cache_control: CacheControlHeader | None

A CacheControlHeader header to add to route handlers of this controller.

Can be overridden by route handlers.

dependencies: Dependencies | None

A string keyed dictionary of dependency Provider instances.

dto: type[AbstractDTO] | None | EmptyType

AbstractDTO to use for (de)serializing and validation of request data.

etag: ETag | None

An etag header of type ETag to add to route handlers of this controller.

Can be overridden by route handlers.

exception_handlers: ExceptionHandlersMap | None

A map of handler functions to status codes and/or exception types.

guards: Sequence[Guard] | None

A sequence of Guard callables.

include_in_schema: bool | EmptyType

A boolean flag dictating whether the route handler should be documented in the OpenAPI schema

middleware: Sequence[Middleware] | None

A sequence of Middleware.

opt: Mapping[str, Any] | None

A string key mapping of arbitrary values that can be accessed in Guards or wherever you have access to Request or ASGI Scope.

owner: Router

The Router or Litestar app that owns the controller.

This value is set internally by Litestar and it should not be set when subclassing the controller.

parameters: ParametersMap | None

A mapping of Parameter definitions available to all application paths.

path: str

A path fragment for the controller.

All route handlers under the controller will have the fragment appended to them. If not set it defaults to /.

request_class: type[Request] | None

A custom subclass of Request to be used as the default request for all route handlers under the controller.

request_max_body_size: int | None | EmptyType

Maximum allowed size of the request body in bytes. If this size is exceeded, a ‘413 - Request Entity Too Large’ error response is returned.

response_class: type[Response] | None

A custom subclass of Response to be used as the default response for all route handlers under the controller.

response_cookies: ResponseCookies | None

A list of Cookie instances.

response_headers: ResponseHeaders | None

A string keyed dictionary mapping ResponseHeader instances.

return_dto: type[AbstractDTO] | None | EmptyType

AbstractDTO to use for serializing outbound response data.

security: Sequence[SecurityRequirement] | None

A sequence of dictionaries that to the schema of all route handlers under the controller.

signature_namespace: dict[str, Any]

A mapping of names to types for use in forward reference resolution during signature modelling.

signature_types: Sequence[Any]

A sequence of types for use in forward reference resolution during signature modelling.

These types will be added to the signature namespace using their __name__ attribute.

tags: Sequence[str] | None

A sequence of string tags that will be appended to the schema of all route handlers under the controller.

type_decoders: TypeDecodersSequence | None

A sequence of tuples, each composed of a predicate testing for type identity and a msgspec hook for deserialization.

type_encoders: TypeEncodersMap | None

A mapping of types to callables that transform them into types supported for serialization.

websocket_class: type[WebSocket] | None

A custom subclass of WebSocket to be used as the default websocket for all route handlers under the controller.

create_work_group(fn) = <litestar.handlers.http_handlers.decorators.post object>
delete_work_group(fn) = <litestar.handlers.http_handlers.decorators.delete object>
get_work_group(fn) = <litestar.handlers.http_handlers.decorators.get object>
get_work_group_by_slug(fn) = <litestar.handlers.http_handlers.decorators.get object>
list_active_work_groups(fn) = <litestar.handlers.http_handlers.decorators.get object>
list_work_groups(fn) = <litestar.handlers.http_handlers.decorators.get object>
update_work_group(fn) = <litestar.handlers.http_handlers.decorators.put object>
class WorkGroupCreate[source]

Bases: WorkGroupBase

Schema for creating a new WorkGroup.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

creator_id: UUID
class WorkGroupList[source]

Bases: BaseModel

Schema for WorkGroup list items.

model_config: ClassVar[ConfigDict] = {'from_attributes': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

id: UUID
slug: str
name: str
active: bool
created_at: datetime.datetime
class WorkGroupRead[source]

Bases: WorkGroupBase

Schema for reading WorkGroup data.

model_config: ClassVar[ConfigDict] = {'from_attributes': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

id: UUID
slug: str
creator_id: UUID
created_at: datetime.datetime
updated_at: datetime.datetime
class WorkGroupRepository[source]

Bases: SQLAlchemyAsyncRepository[WorkGroup]

Repository for WorkGroup database operations.

async get_active_work_groups(limit=100, offset=0)[source]

Get active work groups.

Parameters:
  • limit (int) – Maximum number of work groups to return.

  • offset (int) – Number of work groups to skip.

Return type:

list[WorkGroup]

Returns:

List of active work groups ordered by name.

async get_by_slug(slug)[source]

Get a work group by slug.

Parameters:

slug (str) – The slug to search for.

Return type:

WorkGroup | None

Returns:

The work group if found, None otherwise.

model_type

alias of WorkGroup

class WorkGroupService[source]

Bases: SQLAlchemyAsyncRepositoryService[WorkGroup, Any]

Service for WorkGroup business logic.

async get_active_work_groups(limit=100, offset=0)[source]

Get active work groups.

Parameters:
  • limit (int) – Maximum number of work groups to return.

  • offset (int) – Number of work groups to skip.

Return type:

list[WorkGroup]

Returns:

List of active work groups.

async get_by_slug(slug)[source]

Get a work group by slug.

Parameters:

slug (str) – The slug to search for.

Return type:

WorkGroup | None

Returns:

The work group if found, None otherwise.

match_fields: ClassVar[Optional[Union[list[str], str]]] = ['slug']

List of dialects that prefer to use field.id = ANY(:1) instead of field.id IN (...).

repository_type

alias of WorkGroupRepository

class WorkGroupUpdate[source]

Bases: BaseModel

Schema for updating a WorkGroup.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: Annotated[str, Field(min_length=1, max_length=255)] | None
purpose: str | None
active: bool | None
url: str | None
class WorkGroupsPageController[source]

Bases: Controller

Controller for work groups HTML pages.

after_request: AfterRequestHookHandler | None

A sync or async function executed before a Request is passed to any route handler.

If this function returns a value, the request will not reach the route handler, and instead this value will be used.

after_response: AfterResponseHookHandler | None

A sync or async function called after the response has been awaited.

It receives the Request instance and should not return any values.

before_request: BeforeRequestHookHandler | None

A sync or async function called immediately before calling the route handler.

It receives the Request instance and any non-None return value is used for the response, bypassing the route handler.

cache_control: CacheControlHeader | None

A CacheControlHeader header to add to route handlers of this controller.

Can be overridden by route handlers.

dependencies: Dependencies | None

A string keyed dictionary of dependency Provider instances.

dto: type[AbstractDTO] | None | EmptyType

AbstractDTO to use for (de)serializing and validation of request data.

etag: ETag | None

An etag header of type ETag to add to route handlers of this controller.

Can be overridden by route handlers.

exception_handlers: ExceptionHandlersMap | None

A map of handler functions to status codes and/or exception types.

guards: Sequence[Guard] | None

A sequence of Guard callables.

include_in_schema: bool | EmptyType

A boolean flag dictating whether the route handler should be documented in the OpenAPI schema

middleware: Sequence[Middleware] | None

A sequence of Middleware.

opt: Mapping[str, Any] | None

A string key mapping of arbitrary values that can be accessed in Guards or wherever you have access to Request or ASGI Scope.

owner: Router

The Router or Litestar app that owns the controller.

This value is set internally by Litestar and it should not be set when subclassing the controller.

parameters: ParametersMap | None

A mapping of Parameter definitions available to all application paths.

path: str

A path fragment for the controller.

All route handlers under the controller will have the fragment appended to them. If not set it defaults to /.

request_class: type[Request] | None

A custom subclass of Request to be used as the default request for all route handlers under the controller.

request_max_body_size: int | None | EmptyType

Maximum allowed size of the request body in bytes. If this size is exceeded, a ‘413 - Request Entity Too Large’ error response is returned.

response_class: type[Response] | None

A custom subclass of Response to be used as the default response for all route handlers under the controller.

response_cookies: ResponseCookies | None

A list of Cookie instances.

response_headers: ResponseHeaders | None

A string keyed dictionary mapping ResponseHeader instances.

return_dto: type[AbstractDTO] | None | EmptyType

AbstractDTO to use for serializing outbound response data.

security: Sequence[SecurityRequirement] | None

A sequence of dictionaries that to the schema of all route handlers under the controller.

signature_namespace: dict[str, Any]

A mapping of names to types for use in forward reference resolution during signature modelling.

signature_types: Sequence[Any]

A sequence of types for use in forward reference resolution during signature modelling.

These types will be added to the signature namespace using their __name__ attribute.

tags: Sequence[str] | None

A sequence of string tags that will be appended to the schema of all route handlers under the controller.

type_decoders: TypeDecodersSequence | None

A sequence of tuples, each composed of a predicate testing for type identity and a msgspec hook for deserialization.

type_encoders: TypeEncodersMap | None

A mapping of types to callables that transform them into types supported for serialization.

websocket_class: type[WebSocket] | None

A custom subclass of WebSocket to be used as the default websocket for all route handlers under the controller.

work_group_detail(fn) = <litestar.handlers.http_handlers.decorators.get object>
work_groups_index(fn) = <litestar.handlers.http_handlers.decorators.get object>
get_work_groups_dependencies()[source]

Get all work groups domain dependency providers.

Return type:

dict

Models

Work Groups domain models.

class WorkGroup[source]

Bases: AuditBase, SlugMixin

name: Mapped[str]
purpose: Mapped[str]
active: Mapped[bool]
url: Mapped[str | None]
creator_id: Mapped[UUID]
__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

created_at: Mapped[datetime.datetime]

Date/time of instance creation.

id: Mapped[UUID]

UUID Primary key column.

slug: Mapped[str]
updated_at: Mapped[datetime.datetime]

Date/time of instance last update.

Schemas

Work Groups domain Pydantic schemas.

class WorkGroupBase[source]

Bases: BaseModel

Base WorkGroup schema with common fields.

name: Annotated[str, Field(min_length=1, max_length=255)]
purpose: str
active: bool
url: str | None
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class WorkGroupCreate[source]

Bases: WorkGroupBase

Schema for creating a new WorkGroup.

creator_id: UUID
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: Annotated[str, Field(min_length=1, max_length=255)]
purpose: str
active: bool
url: str | None
class WorkGroupUpdate[source]

Bases: BaseModel

Schema for updating a WorkGroup.

name: Annotated[str, Field(min_length=1, max_length=255)] | None
purpose: str | None
active: bool | None
url: str | None
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class WorkGroupRead[source]

Bases: WorkGroupBase

Schema for reading WorkGroup data.

id: UUID
slug: str
creator_id: UUID
created_at: datetime.datetime
updated_at: datetime.datetime
model_config: ClassVar[ConfigDict] = {'from_attributes': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: Annotated[str, Field(min_length=1, max_length=255)]
purpose: str
active: bool
url: str | None
class WorkGroupList[source]

Bases: BaseModel

Schema for WorkGroup list items.

id: UUID
slug: str
name: str
active: bool
created_at: datetime.datetime
model_config: ClassVar[ConfigDict] = {'from_attributes': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

Repositories

Work Groups domain repositories for database access.

class WorkGroupRepository[source]

Bases: SQLAlchemyAsyncRepository[WorkGroup]

Repository for WorkGroup database operations.

model_type

alias of WorkGroup

async get_by_slug(slug)[source]

Get a work group by slug.

Parameters:

slug (str) – The slug to search for.

Return type:

WorkGroup | None

Returns:

The work group if found, None otherwise.

async get_active_work_groups(limit=100, offset=0)[source]

Get active work groups.

Parameters:
  • limit (int) – Maximum number of work groups to return.

  • offset (int) – Number of work groups to skip.

Return type:

list[WorkGroup]

Returns:

List of active work groups ordered by name.

Services

Work Groups domain services for business logic.

class WorkGroupService[source]

Bases: SQLAlchemyAsyncRepositoryService[WorkGroup, Any]

Service for WorkGroup business logic.

repository_type

alias of WorkGroupRepository

match_fields: ClassVar[Optional[Union[list[str], str]]] = ['slug']

List of dialects that prefer to use field.id = ANY(:1) instead of field.id IN (...).

async get_by_slug(slug)[source]

Get a work group by slug.

Parameters:

slug (str) – The slug to search for.

Return type:

WorkGroup | None

Returns:

The work group if found, None otherwise.

async get_active_work_groups(limit=100, offset=0)[source]

Get active work groups.

Parameters:
  • limit (int) – Maximum number of work groups to return.

  • offset (int) – Number of work groups to skip.

Return type:

list[WorkGroup]

Returns:

List of active work groups.

Controllers

Work Groups domain API and page controllers.

class WorkGroupController[source]

Bases: Controller

Controller for WorkGroup CRUD operations.

path: str

A path fragment for the controller.

All route handlers under the controller will have the fragment appended to them. If not set it defaults to /.

tags: Sequence[str] | None

A sequence of string tags that will be appended to the schema of all route handlers under the controller.

list_work_groups(fn) = <litestar.handlers.http_handlers.decorators.get object>
get_work_group(fn) = <litestar.handlers.http_handlers.decorators.get object>
get_work_group_by_slug(fn) = <litestar.handlers.http_handlers.decorators.get object>
list_active_work_groups(fn) = <litestar.handlers.http_handlers.decorators.get object>
create_work_group(fn) = <litestar.handlers.http_handlers.decorators.post object>
update_work_group(fn) = <litestar.handlers.http_handlers.decorators.put object>
delete_work_group(fn) = <litestar.handlers.http_handlers.decorators.delete object>
after_request: AfterRequestHookHandler | None

A sync or async function executed before a Request is passed to any route handler.

If this function returns a value, the request will not reach the route handler, and instead this value will be used.

after_response: AfterResponseHookHandler | None

A sync or async function called after the response has been awaited.

It receives the Request instance and should not return any values.

before_request: BeforeRequestHookHandler | None

A sync or async function called immediately before calling the route handler.

It receives the Request instance and any non-None return value is used for the response, bypassing the route handler.

cache_control: CacheControlHeader | None

A CacheControlHeader header to add to route handlers of this controller.

Can be overridden by route handlers.

dependencies: Dependencies | None

A string keyed dictionary of dependency Provider instances.

dto: type[AbstractDTO] | None | EmptyType

AbstractDTO to use for (de)serializing and validation of request data.

etag: ETag | None

An etag header of type ETag to add to route handlers of this controller.

Can be overridden by route handlers.

exception_handlers: ExceptionHandlersMap | None

A map of handler functions to status codes and/or exception types.

guards: Sequence[Guard] | None

A sequence of Guard callables.

include_in_schema: bool | EmptyType

A boolean flag dictating whether the route handler should be documented in the OpenAPI schema

middleware: Sequence[Middleware] | None

A sequence of Middleware.

opt: Mapping[str, Any] | None

A string key mapping of arbitrary values that can be accessed in Guards or wherever you have access to Request or ASGI Scope.

owner: Router

The Router or Litestar app that owns the controller.

This value is set internally by Litestar and it should not be set when subclassing the controller.

parameters: ParametersMap | None

A mapping of Parameter definitions available to all application paths.

request_class: type[Request] | None

A custom subclass of Request to be used as the default request for all route handlers under the controller.

request_max_body_size: int | None | EmptyType

Maximum allowed size of the request body in bytes. If this size is exceeded, a ‘413 - Request Entity Too Large’ error response is returned.

response_class: type[Response] | None

A custom subclass of Response to be used as the default response for all route handlers under the controller.

response_cookies: ResponseCookies | None

A list of Cookie instances.

response_headers: ResponseHeaders | None

A string keyed dictionary mapping ResponseHeader instances.

return_dto: type[AbstractDTO] | None | EmptyType

AbstractDTO to use for serializing outbound response data.

security: Sequence[SecurityRequirement] | None

A sequence of dictionaries that to the schema of all route handlers under the controller.

signature_namespace: dict[str, Any]

A mapping of names to types for use in forward reference resolution during signature modelling.

signature_types: Sequence[Any]

A sequence of types for use in forward reference resolution during signature modelling.

These types will be added to the signature namespace using their __name__ attribute.

type_decoders: TypeDecodersSequence | None

A sequence of tuples, each composed of a predicate testing for type identity and a msgspec hook for deserialization.

type_encoders: TypeEncodersMap | None

A mapping of types to callables that transform them into types supported for serialization.

websocket_class: type[WebSocket] | None

A custom subclass of WebSocket to be used as the default websocket for all route handlers under the controller.

class WorkGroupsPageController[source]

Bases: Controller

Controller for work groups HTML pages.

path: str

A path fragment for the controller.

All route handlers under the controller will have the fragment appended to them. If not set it defaults to /.

include_in_schema: bool | EmptyType

A boolean flag dictating whether the route handler should be documented in the OpenAPI schema

work_groups_index(fn) = <litestar.handlers.http_handlers.decorators.get object>
work_group_detail(fn) = <litestar.handlers.http_handlers.decorators.get object>
after_request: AfterRequestHookHandler | None

A sync or async function executed before a Request is passed to any route handler.

If this function returns a value, the request will not reach the route handler, and instead this value will be used.

after_response: AfterResponseHookHandler | None

A sync or async function called after the response has been awaited.

It receives the Request instance and should not return any values.

before_request: BeforeRequestHookHandler | None

A sync or async function called immediately before calling the route handler.

It receives the Request instance and any non-None return value is used for the response, bypassing the route handler.

cache_control: CacheControlHeader | None

A CacheControlHeader header to add to route handlers of this controller.

Can be overridden by route handlers.

dependencies: Dependencies | None

A string keyed dictionary of dependency Provider instances.

dto: type[AbstractDTO] | None | EmptyType

AbstractDTO to use for (de)serializing and validation of request data.

etag: ETag | None

An etag header of type ETag to add to route handlers of this controller.

Can be overridden by route handlers.

exception_handlers: ExceptionHandlersMap | None

A map of handler functions to status codes and/or exception types.

guards: Sequence[Guard] | None

A sequence of Guard callables.

middleware: Sequence[Middleware] | None

A sequence of Middleware.

opt: Mapping[str, Any] | None

A string key mapping of arbitrary values that can be accessed in Guards or wherever you have access to Request or ASGI Scope.

owner: Router

The Router or Litestar app that owns the controller.

This value is set internally by Litestar and it should not be set when subclassing the controller.

parameters: ParametersMap | None

A mapping of Parameter definitions available to all application paths.

request_class: type[Request] | None

A custom subclass of Request to be used as the default request for all route handlers under the controller.

request_max_body_size: int | None | EmptyType

Maximum allowed size of the request body in bytes. If this size is exceeded, a ‘413 - Request Entity Too Large’ error response is returned.

response_class: type[Response] | None

A custom subclass of Response to be used as the default response for all route handlers under the controller.

response_cookies: ResponseCookies | None

A list of Cookie instances.

response_headers: ResponseHeaders | None

A string keyed dictionary mapping ResponseHeader instances.

return_dto: type[AbstractDTO] | None | EmptyType

AbstractDTO to use for serializing outbound response data.

security: Sequence[SecurityRequirement] | None

A sequence of dictionaries that to the schema of all route handlers under the controller.

signature_namespace: dict[str, Any]

A mapping of names to types for use in forward reference resolution during signature modelling.

signature_types: Sequence[Any]

A sequence of types for use in forward reference resolution during signature modelling.

These types will be added to the signature namespace using their __name__ attribute.

tags: Sequence[str] | None

A sequence of string tags that will be appended to the schema of all route handlers under the controller.

type_decoders: TypeDecodersSequence | None

A sequence of tuples, each composed of a predicate testing for type identity and a msgspec hook for deserialization.

type_encoders: TypeEncodersMap | None

A mapping of types to callables that transform them into types supported for serialization.

websocket_class: type[WebSocket] | None

A custom subclass of WebSocket to be used as the default websocket for all route handlers under the controller.

Dependencies

Work Groups domain dependency injection providers.

async provide_work_group_repository(db_session)[source]

Provide a WorkGroupRepository instance.

Return type:

WorkGroupRepository

async provide_work_group_service(db_session)[source]

Provide a WorkGroupService instance.

Return type:

WorkGroupService

get_work_groups_dependencies()[source]

Get all work groups domain dependency providers.

Return type:

dict