diff options
| author | J08nY | 2017-07-07 20:06:56 +0200 |
|---|---|---|
| committer | J08nY | 2017-07-07 20:06:56 +0200 |
| commit | 888da7e2ca9d475d1e27b58e425ed8c8d1a0cd42 (patch) | |
| tree | c38bfa7eb36932de45cc19799fcfeb52b8fd674b /src/mailman_pgp/rest/lists.py | |
| parent | 3c15bcc9b8a838439de4301f8c9f1a73b522ac4b (diff) | |
| download | mailman-pgp-888da7e2ca9d475d1e27b58e425ed8c8d1a0cd42.tar.gz mailman-pgp-888da7e2ca9d475d1e27b58e425ed8c8d1a0cd42.tar.zst mailman-pgp-888da7e2ca9d475d1e27b58e425ed8c8d1a0cd42.zip | |
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)) |
