Skip to content

Conversation

@nnpvaan
Copy link
Contributor

@nnpvaan nnpvaan commented Oct 23, 2025

Description of the issue/feature this PR addresses

This PR adds compatibility for IInfo adapters in user info retrieval, enabling custom extensions to dynamically enhance the user API response.
It also adds a new IUsersFilter interface to allow flexible and extensible user filtering during query operations.

Current behavior before PR

  • User data retrieval is limited to default fields without adapter-based extensions.
  • Filtering logic cannot be customized or extended by other add-ons.

Desired behavior after PR is merged

  • User info can be extended through registered IInfo adapters.
  • User queries can be dynamically filtered using IUsersFilter implementations, providing more control and modularity for custom add-ons.

--
I confirm I have tested the PR thoroughly and coded it according to PEP8
standards.

Copy link
Member

@xispa xispa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @nnpvaan. I've left two comments.

Would you mind adding some documentation about the IUsersFilter adapter in the Customizing section of the documentation?

It would also be great if you could extend the users doctest to include examples for both the IUsersFilter and IInfo adapters. You can refer to the push doctest for an example of how to create a DummyAdapter for convenience.

continue
info[k] = v

for _, adapter in getAdapters((pu,), IInfo):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better use name. As a general rule, we use _ for instances of MessageFactory

user_ids = [username]

# Allow addons to filter the user list via adapters
for _, adapter in getAdapters((request,), IUsersFilter):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as before. Use name instead of _


# Allow addons to filter the user list via adapters
for _, adapter in getAdapters((request,), IUsersFilter):
user_ids = adapter.filter(user_ids) or user_ids
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove the or user_ids condition to avoid returning the full list when the adapter has already filtered all entries.

Besides, If I request a user by a specific username, I'd expect the system to return that user regardless. Therefore, this filtering should only be applied when no username is provided (i.e., when username is None).

@nnpvaan nnpvaan requested a review from xispa October 27, 2025 06:40
@nnpvaan
Copy link
Contributor Author

nnpvaan commented Oct 27, 2025

Hi @xispa, I added the documentation and the doctest for extend adapters. Please help me review it again.

Copy link
Member

@xispa xispa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent, thanks!

@xispa xispa merged commit 2443c10 into senaite:2.x Oct 27, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants