コード例 #1
0
 def all(self):
     try:
         return getattr(get_mailman_client(), self.resource_name_plural)
     except AttributeError:
         raise MailmanApiError
     except MailmanConnectionError as e:
         raise MailmanApiError(e)
コード例 #2
0
 def all(self, advertised=False):
     try:
         method = getattr(get_mailman_client(),
                          'get_' + self.resource_name_plural)
         return method(advertised=advertised)
     except AttributeError:
         raise MailmanApiError
     except MailmanConnectionError as e:
         raise MailmanApiError(e)
コード例 #3
0
 def _get_context_obj(self):
     if self.context == 'list':
         obj = List.objects.get_or_404(fqdn_listname=self.identifier)
     elif self.context == 'domain':
         obj = Domain.objects.get_or_404(mail_host=self.identifier)
     elif self.context == 'site':
         obj = get_mailman_client()
     else:
         obj = None
     return obj
コード例 #4
0
 def get(self, *args, **kwargs):
     try:
         method = getattr(get_mailman_client(), 'get_' + self.resource_name)
         return method(*args, **kwargs)
     except AttributeError as e:
         raise MailmanApiError(e)
     except HTTPError as e:
         if e.code == 404:
             raise Mailman404Error('Mailman resource could not be found.')
         else:
             raise
     except MailmanConnectionError as e:
         raise MailmanApiError(e)
コード例 #5
0
 def create(self, *args, **kwargs):
     try:
         method = getattr(get_mailman_client(),
                          'create_' + self.resource_name)
         return method(*args, **kwargs)
     except AttributeError as e:
         raise MailmanApiError(e)
     except HTTPError as e:
         if e.code == 409:
             raise MailmanApiError
         else:
             raise
     except MailmanConnectionError:
         raise MailmanApiError