do not fail creating subjects list on bad data

This commit is contained in:
Frédéric Péters 2011-10-07 17:21:59 -04:00
parent f375f4c6d6
commit 30cb1879c4
1 changed files with 6 additions and 1 deletions

View File

@ -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):