diff --git a/roundup/cgi/templating.py b/roundup/cgi/templating.py index be880fc..1dc3581 100644 --- a/roundup/cgi/templating.py +++ b/roundup/cgi/templating.py @@ -2394,6 +2394,10 @@ class MultilinkHTMLProperty(HTMLProperty): if value is None: value = self._value + # When rendering from form contents, 'value' may contain + # elements starting '-' from '- no selection -' having been + # selected on a previous form submission. + value = [v for v in value if not v.startswith('-')] linkcl = self._db.getclass(self._prop.classname) diff --git a/roundup/hyperdb.py b/roundup/hyperdb.py index 2b9a29f..f5232d5 100644 --- a/roundup/hyperdb.py +++ b/roundup/hyperdb.py @@ -258,8 +258,11 @@ class Multilink(_Pointer): try: curvalue.remove(itemid) except ValueError: - raise HyperdbValueError(_('property %s: %r is not ' \ - 'currently an element')%(propname, item)) + # This can occur if the edit adding the element + # produced an error, so the form has it in the + # "no selection" choice but it's not set in the + # database. + pass else: newvalue.append(itemid) if itemid not in curvalue: diff --git a/test/test_hyperdbvals.py b/test/test_hyperdbvals.py index 827a2f3..9de4c71 100644 --- a/test/test_hyperdbvals.py +++ b/test/test_hyperdbvals.py @@ -183,9 +183,6 @@ class RawToHyperdbTest(unittest.TestCase): self.assertEqual(self._test('multilink3', '', None), []) - with self.assertRaises(hyperdb.HyperdbValueError) as cm: - result = self._test('multilink3', '-valid', None) - self.assertEqual(cm.exception.args, - ("property multilink3: 'valid' is not currently an element",)) + self.assertEqual(self._test('multilink3', '-valid', None), []) # vim: set filetype=python ts=4 sw=4 et si