Allow FieldAttribute lists and sets to be set from a comma separated string

pull/15204/head
Toshio Kuratomi 9 years ago committed by James Cammarata
parent 7ddce864a1
commit 61afb71c09

@ -334,7 +334,10 @@ class Base:
if value is None:
value = []
elif not isinstance(value, list):
value = [ value ]
if isinstance(value, string_types):
value = value.split(',')
else:
value = [ value ]
if attribute.listof is not None:
for item in value:
if not isinstance(item, attribute.listof):
@ -346,11 +349,15 @@ class Base:
elif attribute.isa == 'set':
if value is None:
value = set()
else:
if not isinstance(value, (list, set)):
elif not isinstance(value, (list, set)):
if isinstance(value, string_types):
value = value.split(',')
else:
# Making a list like this handles strings of
# text and bytes properly
value = [ value ]
if not isinstance(value, set):
value = set(value)
if not isinstance(value, set):
value = set(value)
elif attribute.isa == 'dict':
if value is None:
value = dict()

Loading…
Cancel
Save