Introduce WebAPIResource.serialize_object_list for serializing lists.

Review Request #14298 — Created Jan. 20, 2025 and submitted — Latest diff uploaded

Information

Djblets
release-5.x

Reviewers

This adds a new WebAPIResource.serialize_object_list() method and
serialize_object_list_func argument to WebAPIResponsePaginated.
These allow an implementation to pre-process the list of items going
into a response, or to post-process or replace the serialized result.

The main use case is to allow resources to perform additional logic
across the list of items before or after serializing, such as
bulk-fetching extra data from cache or extensions hooks to include in
results.

Unit tests pass.

Diff Revision 2 (Latest)

orig
1
2

Commits

First Last Summary ID Author
Introduce WebAPIResource.serialize_object_list for serializing lists.
This adds a new `WebAPIResource.serialize_object_list()` method and `serialize_object_list_func` argument to `WebAPIResponsePaginated`. These allow an implementation to pre-process the list of items going into a response, or to post-process or replace the serialized result. The main use case is to allow resources to perform additional logic across the list of items before or after serializing, such as bulk-fetching extra data from cache or extensions hooks to include in results.
356f4b5b88528d427e53302113c9403a46f60894 Christian Hammond
djblets/webapi/responses.py
djblets/webapi/resources/base.py
djblets/webapi/tests/test_responses.py
djblets/webapi/tests/test_webapiresource.py
Loading...