diff --git a/src/postorius/models.py b/src/postorius/models.py index cb79995..a11584b 100644 --- a/src/postorius/models.py +++ b/src/postorius/models.py @@ -84,21 +84,21 @@ return getattr(get_client(), self.resource_name_plural) except AttributeError: raise MailmanApiError - except MailmanConnectionError, e: + except MailmanConnectionError as e: raise MailmanApiError(e) def get(self, **kwargs): try: method = getattr(get_client(), 'get_' + self.resource_name) return method(**kwargs) - except AttributeError, e: + except AttributeError as e: raise MailmanApiError(e) - except HTTPError, e: + except HTTPError as e: if e.code == 404: raise Mailman404Error('Mailman resource could not be found.') else: raise - except MailmanConnectionError, e: + except MailmanConnectionError as e: raise MailmanApiError(e) def get_or_404(self, **kwargs): @@ -108,16 +108,16 @@ return self.get(**kwargs) except Mailman404Error: raise Http404 - except MailmanConnectionError, e: + except MailmanConnectionError as e: raise MailmanApiError(e) def create(self, **kwargs): try: method = getattr(get_client(), 'create_' + self.resource_name) return method(**kwargs) - except AttributeError, e: + except AttributeError as e: raise MailmanApiError(e) - except HTTPError, e: + except HTTPError as e: if e.code == 409: raise MailmanApiError else: @@ -142,7 +142,7 @@ objects = getattr(get_client(), self.resource_name_plural) except AttributeError: raise MailmanApiError - except MailmanConnectionError, e: + except MailmanConnectionError as e: raise MailmanApiError(e) if only_public: public = [] diff --git a/src/postorius/views/list.py b/src/postorius/views/list.py index 9d5d986..890e6cc 100644 --- a/src/postorius/views/list.py +++ b/src/postorius/views/list.py @@ -124,7 +124,7 @@ settingsform = UserPreferences(initial=mm_member.preferences) except MailmanApiError: return utils.render_api_error(request) - except HTTPError, e: + except HTTPError as e: messages.error(request, e.msg) return render_to_response( 'postorius/lists/memberoptions.html', @@ -243,7 +243,7 @@ 'Please try again.') except MailmanApiError: return utils.render_api_error(request) - except HTTPError, e: + except HTTPError as e: messages.error(request, e.msg) return redirect('list_summary', self.mailing_list.list_id) @@ -285,7 +285,7 @@ 'Please try again.') except MailmanApiError: return utils.render_api_error(request) - except HTTPError, e: + except HTTPError as e: messages.error(request, e.msg) return redirect('list_summary', self.mailing_list.list_id) @@ -304,7 +304,7 @@ email) except MailmanApiError: return utils.render_api_error(request) - except ValueError, e: + except ValueError as e: messages.error(request, e) return redirect('list_summary', self.mailing_list.list_id) @@ -336,7 +336,7 @@ (email, self.mailing_list.fqdn_listname)) except MailmanApiError: return utils.render_api_error(request) - except HTTPError, e: + except HTTPError as e: messages.error(request, e) except ValidationError: messages.error(request, @@ -372,9 +372,7 @@ (email, self.mailing_list.fqdn_listname)) except MailmanApiError: return utils.render_api_error(request) - except HTTPError, e: - messages.error(request, e) - except ValueError, e: + except (HTTPError, ValueError) as e: messages.error(request, e) except ValidationError: messages.error(request, @@ -451,7 +449,7 @@ return redirect("list_summary", list_id=mailing_list.list_id) # TODO catch correct Error class: - except HTTPError, e: + except HTTPError as e: return render_to_response( 'postorius/errors/generic.html', {'error': e}, context_instance=RequestContext(request)) @@ -634,7 +632,7 @@ the_list.accept_message(msg_id) except MailmanApiError: return utils.render_api_error(request) - except HTTPError, e: + except HTTPError as e: messages.error(request, e.msg) return redirect('list_held_messages', the_list.list_id) messages.success(request, 'The message has been accepted.') @@ -650,7 +648,7 @@ the_list.discard_message(msg_id) except MailmanApiError: return utils.render_api_error(request) - except HTTPError, e: + except HTTPError as e: messages.error(request, e.msg) return redirect('list_held_messages', the_list.list_id) messages.success(request, 'The message has been discarded.') @@ -666,7 +664,7 @@ the_list.defer_message(msg_id) except MailmanApiError: return utils.render_api_error(request) - except HTTPError, e: + except HTTPError as e: messages.error(request, e.msg) return redirect('list_held_messages', the_list.list_id) messages.success(request, 'The message has been deferred.') @@ -682,7 +680,7 @@ the_list.reject_message(msg_id) except MailmanApiError: return utils.render_api_error(request) - except HTTPError, e: + except HTTPError as e: messages.error(request, e.msg) return redirect('list_held_messages', the_list.list_id) messages.success(request, 'The message has been rejected.') @@ -771,7 +769,7 @@ try: m_list = List.objects.get_or_404(fqdn_listname=list_id) list_settings = m_list.settings - except MailmanApiError, HTTPError: + except (MailmanApiError, HTTPError): return utils.render_api_error(request) # List settings are grouped an processed in different forms. if form_class: @@ -894,7 +892,7 @@ messages.success(request, 'All members have been unsubscribed from the list.') return redirect('list_members', mlist.list_id) - except Exception, e: + except Exception as e: messages.error(request, e) return render_to_response('postorius/lists/confirm_removeall_subscribers.html', {'list_id': mlist.list_id}, diff --git a/src/postorius/views/settings.py b/src/postorius/views/settings.py index 43e24f2..a73167a 100644 --- a/src/postorius/views/settings.py +++ b/src/postorius/views/settings.py @@ -78,7 +78,7 @@ domain.save() except MailmanApiError: return utils.render_api_error(request) - except HTTPError, e: + except HTTPError as e: messages.error(request, e) else: messages.success(request, _("New Domain registered")) @@ -101,7 +101,6 @@ _('The domain %s has been deleted.' % domain)) return redirect("domain_index") except HTTPError as e: - print e.__dict__ messages.error(request, _('The domain could not be deleted:' ' %s' % e.msg)) return redirect("domain_index") diff --git a/src/postorius/views/user.py b/src/postorius/views/user.py index d4aabc8..950b6c4 100644 --- a/src/postorius/views/user.py +++ b/src/postorius/views/user.py @@ -106,7 +106,7 @@ messages.error(request, 'Something went wrong.') except MailmanApiError: return utils.render_api_error(request) - except HTTPError, e: + except HTTPError as e: messages.error(request, e.msg) return redirect("user_address_preferences") @@ -162,7 +162,7 @@ messages.error(request, 'Something went wrong.') except MailmanApiError: return utils.render_api_error(request) - except HTTPError, e: + except HTTPError as e: messages.error(request, e.msg) return redirect("user_subscription_preferences") @@ -290,7 +290,7 @@ user.save() except MailmanApiError: return utils.render_api_error(request) - except HTTPError, e: + except HTTPError as e: messages.error(request, e) else: messages.success(request, _("New User registered"))