Re: [Mailman-Developers] mailman.client and UUIDs for user.user_id
So Aurelien and Florian, what do you think? Should we use the hex representation of the UUID and should I keep backward compatibility. If we can't see any valid reason for converting to ints today, I would personally vote for not converting in the REST API, and for mailman.client to return the UUID object (not the hex string), because I think a python client library should expose python idoms and objects when possible. If we do that, keeping backwards compatibility could be useful indeed, and you can start from my change here: http://bazaar.launchpad.net/~abompard/mailman.client/uuids/revision/58 But FYI, I have already adapted my code in HyperKitty to do the conversion to UUIDs, so I really don't mind if we keep the status quo. Let's just do what's best in the long run. A. ___ Mailman-Developers mailing list Mailman-Developers@python.org https://mail.python.org/mailman/listinfo/mailman-developers Mailman FAQ: http://wiki.list.org/x/AgA3 Searchable Archives: http://www.mail-archive.com/mailman-developers%40python.org/ Unsubscribe: https://mail.python.org/mailman/options/mailman-developers/archive%40jab.org Security Policy: http://wiki.list.org/x/QIA9
Re: [Mailman-Developers] mailman.client and UUIDs for user.user_id
Hi Florian! I think mailmanclient should not expose a different value as the REST API does (the fact that it's an int representation of a uuid isn't exactly obvious from the outside, so a non-explicit conversion could potentially lead to some confusion). Hmm, to me the current situation is more confusing, since the user_id property I get from the REST API is different from the one I find in the database. I guess it depends on the reason the UUID is serialized. If it's to avoid being messed up during the transport, it's a transport issue and I think the library should convert it back (but the original ascii string should not be a problem so it's probably not that. Anyone remembers why the REST API exposes the int value instead of the string? It happened in commit 7043 but the reason is not given in the commit message. But how about we add a `uuid` property to the user object which exposes the original uuid value? Not sure that's useful, converting it back to an UUID is easy enough ( uuid.UUID(int=value) ) A. ___ Mailman-Developers mailing list Mailman-Developers@python.org https://mail.python.org/mailman/listinfo/mailman-developers Mailman FAQ: http://wiki.list.org/x/AgA3 Searchable Archives: http://www.mail-archive.com/mailman-developers%40python.org/ Unsubscribe: https://mail.python.org/mailman/options/mailman-developers/archive%40jab.org Security Policy: http://wiki.list.org/x/QIA9
Re: [Mailman-Developers] mailman.client and UUIDs for user.user_id
If the user_id value changes depending on whether you are using the API directly via HTTP or through mailmanclient, that might be hard to understand. Ah, very good point. I'll do the conversion myself then I guess. A. ___ Mailman-Developers mailing list Mailman-Developers@python.org https://mail.python.org/mailman/listinfo/mailman-developers Mailman FAQ: http://wiki.list.org/x/AgA3 Searchable Archives: http://www.mail-archive.com/mailman-developers%40python.org/ Unsubscribe: https://mail.python.org/mailman/options/mailman-developers/archive%40jab.org Security Policy: http://wiki.list.org/x/QIA9
[Mailman-Developers] mailman.client and UUIDs for user.user_id
Hey folks, Mailman stores user_ids as UUIDs in the database, and they are converted on the fly to integers by the REST API. However, the mailmanclient library do not convert them back to UUID. Do you think this is something that it should do, or should I handle this conversion in my own code? FYI, I'm attaching a very simple patch which does this conversion in mailmanclient (4 lines changed). Aurélien === modified file 'src/mailmanclient/_client.py' --- src/mailmanclient/_client.py 2014-04-22 12:35:29 + +++ src/mailmanclient/_client.py 2014-10-27 15:35:08 + @@ -27,6 +27,7 @@ import re import json +from uuid import UUID from base64 import b64encode from httplib2 import Http @@ -644,7 +645,7 @@ @property def addresses(self): -return _Addresses(self._connection, self.user_id) +return _Addresses(self._connection, self.user_id.int) @property def display_name(self): @@ -668,7 +669,7 @@ @property def user_id(self): self._get_info() -return self._info['user_id'] +return UUID(int=self._info['user_id']) @property def created_on(self): @@ -708,7 +709,7 @@ @property def preferences(self): if self._preferences is None: -path = 'users/{0}/preferences'.format(self.user_id) +path = 'users/{0}/preferences'.format(self.user_id.int) self._preferences = _Preferences(self._connection, path) return self._preferences ___ Mailman-Developers mailing list Mailman-Developers@python.org https://mail.python.org/mailman/listinfo/mailman-developers Mailman FAQ: http://wiki.list.org/x/AgA3 Searchable Archives: http://www.mail-archive.com/mailman-developers%40python.org/ Unsubscribe: https://mail.python.org/mailman/options/mailman-developers/archive%40jab.org Security Policy: http://wiki.list.org/x/QIA9