diff --git a/helios/datatypes/__init__.py b/helios/datatypes/__init__.py index 98b3ad77a676125a77f68152671322ef994224c6..7eaf0e45601de7fb5ce41e29867d685e442c0296 100644 --- a/helios/datatypes/__init__.py +++ b/helios/datatypes/__init__.py @@ -171,7 +171,10 @@ class LDObject(object): self.structured_fields[f] = sub_ld_object # set the field on the wrapped object too - self._setattr_wrapped(f, sub_ld_object.wrapped_obj) + if sub_ld_object != None: + self._setattr_wrapped(f, sub_ld_object.wrapped_obj) + else: + self._setattr_wrapped(f, None) else: # a simple type new_val = self.process_value_in(f, d[f]) @@ -203,6 +206,10 @@ class LDObject(object): @classmethod def fromDict(cls, d, type_hint=None): + # null objects + if d == None: + return None + # the LD type is either in d or in type_hint # FIXME: get this from the dictionary itself ld_type = type_hint diff --git a/helios/models.py b/helios/models.py index b0d722f4c712889d559bbd1fc756ca3c11b68c4f..86d6acfa7c5df0299505a2950a0973dee7b8b02d 100644 --- a/helios/models.py +++ b/helios/models.py @@ -480,9 +480,12 @@ class Election(HeliosModel): counts = sorted(enumerate(result), key=lambda(x): x[1]) counts.reverse() + the_max = question['max'] or 1 + the_min = question['min'] or 0 + # if there's a max > 1, we assume that the top MAX win - if question['max'] > 1: - return [c[0] for c in counts[:question['max']]] + if the_max > 1: + return [c[0] for c in counts[:the_max]] # if max = 1, then depends on absolute or relative if question['result_type'] == 'absolute': @@ -490,8 +493,8 @@ class Election(HeliosModel): return [counts[0][0]] else: return [] - - if question['result_type'] == 'relative': + else: + # assumes that anything non-absolute is relative return [counts[0][0]] @property