Skip to content
This repository has been archived by the owner on May 13, 2020. It is now read-only.

Commit

Permalink
Bugfix: when the Choice field value was invalid, dump used to crash.
Browse files Browse the repository at this point in the history
  • Loading branch information
alga committed Oct 17, 2012
1 parent 3072550 commit 044add9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/cipher/configstore/configstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,10 @@ def dump_type_Choice(self, value, field):
if value is None or value == '':
return ''
bound_field = field.bind(self.context)
return bound_field.vocabulary.getTerm(value).token
try:
return bound_field.vocabulary.getTerm(value).token
except LookupError:
return ''

def dump_type_Tuple(self, value, field):
return self.listValueSeparator.join(value) if value else ''
Expand Down
3 changes: 3 additions & 0 deletions src/cipher/configstore/configstore.txt
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,9 @@ Choice
>>> store.load_type_Choice('', field) is None
True

>>> store.dump_type_Choice(3, field)
''

List
~~~~

Expand Down

0 comments on commit 044add9

Please sign in to comment.