def bexclude(form, excluded): """Return a list of all the fields in the given form, except those excluded.""" excluded = set(split_fields(excluded)) return [form[f] for f in form.fields if f not in excluded]
def bfilter(form, fields): """Return only the given fields from the given form (as a list).""" return [form[f] for f in split_fields(fields)]
def test_split_fields(self): tests = ['foo bar baz', 'foo,bar,baz', ('foo', 'bar', 'baz')] for f in tests: self.assertEqual(split_fields(f), ['foo', 'bar', 'baz'])