diff options
Diffstat (limited to 'src/mailman_pgp/rest/lists.py')
| -rw-r--r-- | src/mailman_pgp/rest/lists.py | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/mailman_pgp/rest/lists.py b/src/mailman_pgp/rest/lists.py index 72fa7a4..9141bce 100644 --- a/src/mailman_pgp/rest/lists.py +++ b/src/mailman_pgp/rest/lists.py @@ -16,10 +16,11 @@ # this program. If not, see <http://www.gnu.org/licenses/>. """""" - +from mailman.interfaces.listmanager import IListManager from mailman.rest.helpers import ( child, CollectionMixin, etag, not_found, okay) from public import public +from zope.component import getUtility from mailman_pgp.config import config from mailman_pgp.model.list import PGPMailingList @@ -38,8 +39,8 @@ class _EncryptedBase(CollectionMixin): sign_outgoing=emlist.sign_outgoing, nonencrypted_msg_action=emlist.nonencrypted_msg_action, self_link=self.api.path_to( - '/plugins/{}/lists/{}'.format(config.name, - emlist.list_id))) + '/plugins/{}/lists/{}'.format(config.name, + emlist.list_id))) def _get_collection(self, request): """See `CollectionMixin`.""" @@ -56,9 +57,13 @@ class AllEncryptedLists(_EncryptedBase): @public class AnEncryptedList(_EncryptedBase): - def __init__(self, list_id): - self._mlist = PGPMailingList.query().filter_by( - list_id=list_id).first() + def __init__(self, list_identifier): + manager = getUtility(IListManager) + if '@' in list_identifier: + mlist = manager.get(list_identifier) + else: + mlist = manager.get_by_list_id(list_identifier) + self._mlist = PGPMailingList.for_list(mlist) def on_get(self, request, response): """/lists/<list_id>""" @@ -86,7 +91,6 @@ class AListPubkey: if pubkey is None: return not_found(response) - resource = dict(public_key=str(self._mlist.pubkey), - key_fingerprint=str( - self._mlist.pubkey.fingerprint)) + resource = dict(public_key=str(pubkey), + key_fingerprint=str(pubkey.fingerprint)) return okay(response, etag(resource)) |
