Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormike <michael.jmontcalm@gmail.com>2009-12-05 20:13:31 (GMT)
committer mike <michael.jmontcalm@gmail.com>2009-12-05 20:13:31 (GMT)
commit933254e3e89be1be6709058621b7c9965b1cc27b (patch)
tree2c168b809e0823d3fa07847029fa31dec0e7a6ba
parentf00c6abdf5804a82eb6d94f427de5d2609a2314c (diff)
Creator : reverting property container changes (removing the __id broke the event callback)properties_tests_fix
-rw-r--r--tutorius/TProbe.py2
-rw-r--r--tutorius/properties.py24
2 files changed, 23 insertions, 3 deletions
diff --git a/tutorius/TProbe.py b/tutorius/TProbe.py
index e2fe556..2834f0c 100644
--- a/tutorius/TProbe.py
+++ b/tutorius/TProbe.py
@@ -499,8 +499,6 @@ class ProbeProxy:
@return address identifier used for unsubscribing
"""
LOGGER.debug("ProbeProxy :: Registering event %s", str(hash(event)))
- #if not block:
- # raise RuntimeError("This function does not allow non-blocking mode yet")
# TODO elavoie 2009-07-25 When we will allow for patterns both
# for event types and sources, we will need to revise the lookup
diff --git a/tutorius/properties.py b/tutorius/properties.py
index 91bda77..bfdb32c 100644
--- a/tutorius/properties.py
+++ b/tutorius/properties.py
@@ -140,7 +140,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)