diff options
| author | Aurélien Bompard | 2016-01-12 19:54:36 +0100 |
|---|---|---|
| committer | Barry Warsaw | 2016-01-13 11:36:30 -0500 |
| commit | 5f9634cc11baee8256e037564b362b0631e269fe (patch) | |
| tree | 0bb5e5252c1d09e0f5a6f428e966d8980b6b426e /src/mailman/rest/members.py | |
| parent | 98c074f19492d81ebf5b5c3f4d4f2210aa56230d (diff) | |
| download | mailman-5f9634cc11baee8256e037564b362b0631e269fe.tar.gz mailman-5f9634cc11baee8256e037564b362b0631e269fe.tar.zst mailman-5f9634cc11baee8256e037564b362b0631e269fe.zip | |
Diffstat (limited to 'src/mailman/rest/members.py')
| -rw-r--r-- | src/mailman/rest/members.py | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/mailman/rest/members.py b/src/mailman/rest/members.py index 91db982c7..64e5ba23f 100644 --- a/src/mailman/rest/members.py +++ b/src/mailman/rest/members.py @@ -107,19 +107,21 @@ class MemberCollection(_MemberBase): class AMember(_MemberBase): """A member.""" - def __init__(self, api, member_id_string): - # The member_id_string is the string representation of the member's - # UUID. In API 3.0, the argument is the string representation of the - # int representation of the UUID. In API 3.1 it's the hex. + def __init__(self, api, member_or_id_string): + # The member_or_id_string is either the member's UUID or the string + # representation of the member's UUID. For the latter, in API 3.0, + # the argument is the string representation of the int representation + # of the UUID. In API 3.1 it's the hex. self.api = api - try: - member_id = api.to_uuid(member_id_string) - except ValueError: - # The string argument could not be converted to a UUID. - self._member = None + if isinstance(member_or_id_string, UUID): + member_id = member_or_id_string else: - service = getUtility(ISubscriptionService) - self._member = service.get_member(member_id) + try: + member_id = api.to_uuid(member_or_id_string) + except ValueError: + # The string argument could not be converted to a UUID. + self._member = None + self._member = getUtility(ISubscriptionService).get_member(member_id) def on_get(self, request, response): """Return a single member end-point.""" |
