From 30cb1879c4602948b0b7e00626d7af247e63150c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Fri, 7 Oct 2011 17:21:59 -0400 Subject: [PATCH] do not fail creating subjects list on bad data --- tabellio/contact/form.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tabellio/contact/form.py b/tabellio/contact/form.py index 2c656ad..635a9af 100644 --- a/tabellio/contact/form.py +++ b/tabellio/contact/form.py @@ -47,8 +47,13 @@ class View(grok.View): def get_possible_subjects(context): terms = [] for line in context.context.subjects.splitlines(): - topic, email = line.strip().split('|') + try: + topic, email = line.strip().split('|') + except ValueError: + continue terms.append(SimpleVocabulary.createTerm(topic, topic.encode('ascii', 'replace'), topic)) + if len(terms) == 0: + terms.append(SimpleVocabulary.createTerm('-', '-', '-')) return SimpleVocabulary(terms) class IEffectiveContact(interface.Interface):