diff options
author | erick <erick@sugar-dev-erick.(none)> | 2009-12-05 20:42:51 (GMT) |
---|---|---|
committer | erick <erick@sugar-dev-erick.(none)> | 2009-12-05 20:42:51 (GMT) |
commit | 0e6a6e03c520b86ee36d79d4cd0daf06f84632a3 (patch) | |
tree | c7bf9600b516f2a7aa466c9b13555898e28cb924 /tutorius/properties.py | |
parent | da7f320dc609e744817c311652d82f5ae1113736 (diff) | |
parent | d47b1b969caad10673fb3763a861d202a01bee53 (diff) |
Merge branch 'master' of git://git.sugarlabs.org/tutorius/mainline into frame_integrationframe_integration
Diffstat (limited to 'tutorius/properties.py')
-rw-r--r-- | tutorius/properties.py | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/tutorius/properties.py b/tutorius/properties.py index f273569..07b1645 100644 --- a/tutorius/properties.py +++ b/tutorius/properties.py @@ -138,7 +138,29 @@ class TPropContainer(object): """ Return a deep copy of the dictionary of properties from that object. """ - return deepcopy(self._props) + return deepcopy(self._props) + + def __hash__(self): + """ + Deprecated. + + Property containers should not be used as keys inside dictionary for + the time being. Since containers are mutable, we should definitely + use the addressing mechanism to refer to the containers. + """ + # Many places we use containers as keys to store additional data. + # Since containers are mutable, there is a need for a hash function + # where the result is constant, so we can still lookup old instances. + return self.__id + + # Adding methods for pickling and unpickling an object with + # properties + def __getstate__(self): + return dict(id=self.__id, props=self._props.copy()) + + def __setstate__(self, dict): + self.__id = dict['id'] + self._props.update(dict['props']) def __eq__(self, e2): return (isinstance(e2, type(self)) and self._props == e2._props) |