Skip to content

Commit 6e7d3c7

Browse files
author
Jeroen van der Heijden
committed
Fix multiple event handlers, resolves #9
1 parent b64c920 commit 6e7d3c7

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

thingsdb/model/eventhandler.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@ def on_warning(self, warn):
1919

2020
def on_watch_init(self, data):
2121
thing_dict = data['thing']
22-
thing_id = thing_dict.pop('#')
22+
thing_id = thing_dict['#']
2323
thing = self._collection._things.get(thing_id)
2424
if thing is None:
25-
thing_dict['#'] = thing_id # restore `thing_dict`
2625
logging.debug(
2726
f'Cannot init #{thing_id} since the thing is not registerd '
2827
f'for watching by collection `{self._collection._name}`')
@@ -46,7 +45,7 @@ def on_watch_update(self, data):
4645
f'for watching by collection `{self._collection._name}`')
4746
return
4847

49-
thing.on_update(data['event'], data.pop('jobs'))
48+
thing.on_update(data['event'], data['jobs'])
5049

5150
def on_watch_delete(self, data):
5251
thing_id = data['#']
@@ -62,4 +61,3 @@ def on_watch_stop(self, data):
6261
thing = self._collection._things.get(thing_id)
6362
if thing is not None:
6463
thing.on_stop()
65-

thingsdb/model/thing.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,9 @@ def _job_set(self, pairs):
201201
cls = self.__class__
202202

203203
for k, v in pairs.items():
204+
if k == '#':
205+
continue
206+
204207
prop = cls._props.get(k)
205208
if prop:
206209
convert = prop.vconv

thingsdb/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.6.7'
1+
__version__ = '0.6.8'

0 commit comments

Comments
 (0)