diff options
| author | Feth AREZKI <farezki@edenwall.com> | 2012-02-20 17:03:44 +0100 |
|---|---|---|
| committer | Feth AREZKI <farezki@edenwall.com> | 2012-02-20 17:03:44 +0100 |
| commit | c51c02481bb5ed9d40451372afcb34d0ab4f56a6 (patch) | |
| tree | cf54150a33ee7a9fa68a48b3eac1f859af09560b | |
| parent | 04f8470223fb9f8d1a8b22ac9a9728f0014627bd (diff) | |
| download | ihatemoney-mirror-c51c02481bb5ed9d40451372afcb34d0ab4f56a6.zip ihatemoney-mirror-c51c02481bb5ed9d40451372afcb34d0ab4f56a6.tar.gz ihatemoney-mirror-c51c02481bb5ed9d40451372afcb34d0ab4f56a6.tar.bz2 | |
tolerance to smtp error when creating project
| -rw-r--r-- | budget/web.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/budget/web.py b/budget/web.py index c3736d3..b8ae71d 100644 --- a/budget/web.py +++ b/budget/web.py @@ -3,6 +3,7 @@ from collections import defaultdict from flask import * from flaskext.mail import Mail, Message from flaskext.babel import get_locale, gettext as _ +from smtplib import SMTPRecipientsRefused import werkzeug # local modules @@ -142,10 +143,17 @@ def create_project(): msg = Message(message_title, body=message_body, recipients=[project.contact_email]) - mail.send(msg) + try: + mail.send(msg) + except SMTPRecipientsRefused: + msg_compl = 'Problem sending mail. ' + # TODO: destroy the project and cancel instead? + else: + msg_compl = '' # redirect the user to the next step (invite) - flash(_("The project identifier is %(project)s", project=project.id)) + flash(_("%(msg_compl)sThe project identifier is %(project)s", + msg_compl=msg_compl, project=project.id)) return redirect(url_for(".invite", project_id=project.id)) return render_template("create_project.html", form=form) |
