##// END OF EJS Templates
Simplify the code for picking json serialization functions to expose the logic better
Jason Grout -
Show More
@@ -198,11 +198,10 b' class Widget(LoggingConfigurable):'
198 198 state = {}
199 199 for k in keys:
200 200 f = self.trait_metadata(k, 'serialize')
201 if f is None:
202 f = self._serialize_trait
201 203 value = getattr(self, k)
202 if f is not None:
203 204 state[k] = f(value)
204 else:
205 state[k] = self._serialize_trait(value)
206 205 return state
207 206
208 207 def send(self, content):
@@ -289,10 +288,9 b' class Widget(LoggingConfigurable):'
289 288 for name in self.keys:
290 289 if name in sync_data:
291 290 f = self.trait_metadata(name, 'deserialize')
292 if f is not None:
291 if f is None:
292 f = self._deserialize_trait
293 293 value = f(sync_data[name])
294 else:
295 value = self._deserialize_trait(sync_data[name])
296 294 with self._lock_property(name, value):
297 295 setattr(self, name, value)
298 296
General Comments 0
You need to be logged in to leave comments. Login now