Skip to content

Commit e3fb99b

Browse files
author
Jeroen van der Heijden
authored
Merge pull request #19 from Koos85/master
Thing.on_update strict
2 parents 22c1b98 + 732122e commit e3fb99b

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

thingsdb/model/thing.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def __init_subclass__(cls):
6363
if isinstance(val, str):
6464
val = val,
6565
if isinstance(val, tuple):
66-
prop = cls._props[key] = Prop(*val)
66+
cls._props[key] = Prop(*val)
6767
delattr(cls, key)
6868
elif callable(val) and hasattr(val, '_ev'):
6969
cls._ev_handlers[val._ev] = val
@@ -136,6 +136,9 @@ def _job_add(self, pair):
136136
(k, v), = pair.items()
137137
prop = cls._props.get(k)
138138

139+
if not prop and cls.__STRICT__:
140+
return
141+
139142
try:
140143
set_ = getattr(self, k)
141144
except AttributeError:
@@ -177,11 +180,14 @@ def _job_event(self, data):
177180
def _job_remove(self, pair):
178181
cls = self.__class__
179182
(k, v), = pair.items()
183+
prop = cls._props.get(k)
184+
185+
if not prop and cls.__STRICT__:
186+
return
180187

181188
try:
182189
set_ = getattr(self, k)
183190
except AttributeError:
184-
prop = cls._props.get(k)
185191
if prop:
186192
logging.warning(
187193
f'missing property `{k}` on `{self}` '
@@ -229,6 +235,9 @@ def _job_splice(self, pair):
229235
(k, v), = pair.items()
230236
prop = cls._props.get(k)
231237

238+
if not prop and cls.__STRICT__:
239+
return
240+
232241
try:
233242
arr = getattr(self, k)
234243
except AttributeError:

0 commit comments

Comments
 (0)