Introduce WebAPIResource.serialize_object_list for serializing lists.

Review Request #14298 — Created Jan. 20, 2025 and updated

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.

Summary ID
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
Description From Last Updated

Given that this method isn't using keyword-only args, should we not be adding this to the end of the argument …

daviddavid
david
  1. 
      
  2. djblets/webapi/responses.py (Diff revision 1)
     
     
     
     
    Show all issues

    Given that this method isn't using keyword-only args, should we not be adding this to the end of the argument list instead of before extra_data?

    Also, want to make this use kw-only args?

    1. This is using keyword-only arguments. *args is defined above, placing everything after as a keyword-only argument.

  3. 
      
chipx86
Review request changed
Change Summary:

Fixed passing in request, *args, **kwargs to serialize_object().

Commits:
Summary ID
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.
b802ba686b1ad42b8fd23f5fd65717e8b4fb8908
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

Checks run (1 timed out)

JSHint timed out.
maubin
  1. Ship It!
  2. 
      
david
  1. Ship It!
  2.