From eedb883ced75fec3427e1f3c2cd9fc9f56cf7f6a Mon Sep 17 00:00:00 2001 From: Aurélien Bompard Date: Wed, 2 Dec 2015 12:06:06 +0100 Subject: Update the REST query to use the find() method --- src/mailman/rest/sub_moderation.py | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/mailman/rest/sub_moderation.py b/src/mailman/rest/sub_moderation.py index 5d6ebce7b..2b87b0241 100644 --- a/src/mailman/rest/sub_moderation.py +++ b/src/mailman/rest/sub_moderation.py @@ -122,22 +122,9 @@ class SubscriptionRequests(_ModerationBase, CollectionMixin): self._mlist = mlist def _get_collection(self, request): - # There's currently no better way to query the pendings database for - # all the entries that are associated with subscription holds on this - # mailing list. Brute force iterating over all the pendables. - collection = [] - for token, pendable in getUtility(IPendings): - if 'token_owner' not in pendable: - # This isn't a subscription hold. - continue - list_id = pendable.get('list_id') - if list_id != self._mlist.list_id: - # Either there isn't a list_id field, in which case it can't - # be a subscription hold, or this is a hold for some other - # mailing list. - continue - collection.append(token) - return collection + pendings = getUtility(IPendings).find( + mlist=self._mlist, type='subscription') + return [token for token, pendable in pendings] def on_get(self, request, response): """/lists/listname/requests""" -- cgit v1.2.3-70-g09d2