diff options
| author | Barry Warsaw | 2016-01-13 12:20:40 -0500 |
|---|---|---|
| committer | Barry Warsaw | 2016-01-13 12:20:40 -0500 |
| commit | 187dad97bf278b0ca9d080774072e8fb235154cc (patch) | |
| tree | 060b1575bb8dbe6e518ae359c22d812c9fa48b51 /src | |
| parent | 06159312d09192b1cede8d20b61ff856442426e8 (diff) | |
| download | mailman-187dad97bf278b0ca9d080774072e8fb235154cc.tar.gz mailman-187dad97bf278b0ca9d080774072e8fb235154cc.tar.zst mailman-187dad97bf278b0ca9d080774072e8fb235154cc.zip | |
Diffstat (limited to 'src')
| -rw-r--r-- | src/mailman/core/api.py | 12 | ||||
| -rw-r--r-- | src/mailman/interfaces/api.py | 12 | ||||
| -rw-r--r-- | src/mailman/rest/members.py | 16 |
3 files changed, 19 insertions, 21 deletions
diff --git a/src/mailman/core/api.py b/src/mailman/core/api.py index d23a9ec67..39c108db2 100644 --- a/src/mailman/core/api.py +++ b/src/mailman/core/api.py @@ -51,9 +51,11 @@ class API30: return uuid.int @staticmethod - def to_uuid(uuid_repr): + def to_uuid(uuid): """See `IAPI`.""" - return UUID(int=int(uuid_repr)) + if isinstance(uuid, UUID): + return uuid + return UUID(int=int(uuid)) @implementer(IAPI) @@ -77,6 +79,8 @@ class API31: return uuid.hex @staticmethod - def to_uuid(uuid_repr): + def to_uuid(uuid): """See `IAPI`.""" - return UUID(hex=uuid_repr) + if isinstance(uuid, UUID): + return uuid + return UUID(hex=uuid) diff --git a/src/mailman/interfaces/api.py b/src/mailman/interfaces/api.py index c64f37346..1e1d15d44 100644 --- a/src/mailman/interfaces/api.py +++ b/src/mailman/interfaces/api.py @@ -55,11 +55,11 @@ class IAPI(Interface): def to_uuid(uuid): """Return the UUID from the string representation. - :param uuid: The string representation of the UUID. - :type uuid: str - :return: The UUID converted from the string representation, as - appropriate for the API version. In 3.0, uuid is interpreted as - the integer representation of a UUID, while in 3.1 it is the hex - representation of the UUID. + :param uuid: A UUID, or the string representation of the UUID. + :type uuid: UUID or str + :return: The UUID, converted if needed as appropriate for the + API version. In 3.0, the string representation is + interpreted as an integer, while in 3.1 it is the hex + string. :rtype: UUID """ diff --git a/src/mailman/rest/members.py b/src/mailman/rest/members.py index bb0c8b834..517e55344 100644 --- a/src/mailman/rest/members.py +++ b/src/mailman/rest/members.py @@ -111,18 +111,12 @@ class AMember(_MemberBase): # The member_id is either the member's UUID or the string # representation of the member's UUID. self.api = api - self._member = None service = getUtility(ISubscriptionService) - if isinstance(member_id, UUID): - self._member = service.get_member(member_id) - else: - try: - member_id = api.to_uuid(member_id) - except ValueError: - # The string argument could not be converted to a UUID. - pass - else: - self._member = service.get_member(member_id) + try: + self._member = service.get_member(api.to_uuid(member_id)) + except ValueError: + # The string argument could not be converted to a UUID. + self._member = None def on_get(self, request, response): """Return a single member end-point.""" |
