##// 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 state = {}
198 state = {}
199 for k in keys:
199 for k in keys:
200 f = self.trait_metadata(k, 'serialize')
200 f = self.trait_metadata(k, 'serialize')
201 if f is None:
202 f = self._serialize_trait
201 value = getattr(self, k)
203 value = getattr(self, k)
202 if f is not None:
203 state[k] = f(value)
204 state[k] = f(value)
204 else:
205 state[k] = self._serialize_trait(value)
206 return state
205 return state
207
206
208 def send(self, content):
207 def send(self, content):
@@ -289,10 +288,9 b' class Widget(LoggingConfigurable):'
289 for name in self.keys:
288 for name in self.keys:
290 if name in sync_data:
289 if name in sync_data:
291 f = self.trait_metadata(name, 'deserialize')
290 f = self.trait_metadata(name, 'deserialize')
292 if f is not None:
291 if f is None:
292 f = self._deserialize_trait
293 value = f(sync_data[name])
293 value = f(sync_data[name])
294 else:
295 value = self._deserialize_trait(sync_data[name])
296 with self._lock_property(name, value):
294 with self._lock_property(name, value):
297 setattr(self, name, value)
295 setattr(self, name, value)
298
296
General Comments 0
You need to be logged in to leave comments. Login now