diff options
author | Vincent Vinet <vince.vinet@gmail.com> | 2009-10-19 17:13:52 (GMT) |
---|---|---|
committer | Vincent Vinet <vince.vinet@gmail.com> | 2009-10-19 17:13:52 (GMT) |
commit | 88013b2f9f93c3220812cd3b624db1423ac081ed (patch) | |
tree | f78aba3242a311bbc26ec04edee1970158a1194b /tutorius/properties.py | |
parent | b2fdc81850ee0b922598fc55b655074c1e335cc4 (diff) |
apply code review induced fixes, fix a few discovered bugs, enjoy, rinse and repeat
Diffstat (limited to 'tutorius/properties.py')
-rw-r--r-- | tutorius/properties.py | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/tutorius/properties.py b/tutorius/properties.py index b1c6361..9639010 100644 --- a/tutorius/properties.py +++ b/tutorius/properties.py @@ -98,12 +98,10 @@ class TPropContainer(object): # Providing the hash methods necessary to use TPropContainers # in a dictionary, according to their properties def __hash__(self): - try: - #Return a hash of properties (key, value) sorted by key - return hash(tuple(map(tuple,sorted(self._props.items(), cmp=lambda x, y: cmp(x[0], y[0]))))) - except TypeError: - #FIXME For list properties (and maybe others), hashing will fail, fallback to id - return id(self) + #Return a hash of properties (key, value) sorted by key + #We need to transform the list of property key, value lists into + # a tuple of key, value tuples + return hash(tuple(map(tuple,sorted(self._props.items(), cmp=lambda x, y: cmp(x[0], y[0]))))) def __eq__(self, e2): return self._props.items() == e2._props.items() @@ -230,6 +228,18 @@ class TArrayProperty(TutoriusProperty): self.min_size_limit = MinSizeConstraint(min_size_limit) self.default = self.validate(value) + #Make this thing hashable + def __setstate__(self, state): + self.max_size_limit = MaxSizeConstraint(state["max_size_limit"]) + self.min_size_limit = MinSizeConstraint(state["min_size_limit"]) + self.value = state["value"] + + def __getstate__(self): + return dict( + max_size_limit=self.max_size_limit.limit, + min_size_limit=self.min_size_limit.limit, + value=self.value, + ) class TColorProperty(TutoriusProperty): """ Represents a RGB color with 3 8-bit integer values. @@ -308,8 +318,10 @@ class TUAMProperty(TutoriusProperty): """ Represents a widget of the interface by storing its UAM. """ - # TODO : Pending UAM check-in (LP 355199) - pass + def __init__(self, value=None): + TutoriusProperty.__init__(self) + + self.type = "uam" class TAddonProperty(TutoriusProperty): """ |