Show More
@@ -197,7 +197,7 b' class Widget(LoggingConfigurable):' | |||
|
197 | 197 | keys = self.keys if key is None else [key] |
|
198 | 198 | state = {} |
|
199 | 199 | for k in keys: |
|
200 |
f = self.trait_metadata(k, ' |
|
|
200 | f = self.trait_metadata(k, 'serialize') | |
|
201 | 201 | value = getattr(self, k) |
|
202 | 202 | if f is not None: |
|
203 | 203 | state[k] = f(value) |
@@ -288,11 +288,11 b' class Widget(LoggingConfigurable):' | |||
|
288 | 288 | """Called when a state is received from the front-end.""" |
|
289 | 289 | for name in self.keys: |
|
290 | 290 | if name in sync_data: |
|
291 |
f = self.trait_metadata(name, ' |
|
|
291 | f = self.trait_metadata(name, 'deserialize') | |
|
292 | 292 | if f is not None: |
|
293 | 293 | value = f(sync_data[name]) |
|
294 | 294 | else: |
|
295 |
value = self._ |
|
|
295 | value = self._deserialize_trait(sync_data[name]) | |
|
296 | 296 | with self._lock_property(name, value): |
|
297 | 297 | setattr(self, name, value) |
|
298 | 298 | |
@@ -326,15 +326,15 b' class Widget(LoggingConfigurable):' | |||
|
326 | 326 | else: |
|
327 | 327 | return x # Value must be JSON-able |
|
328 | 328 | |
|
329 |
def _ |
|
|
329 | def _deserialize_trait(self, x): | |
|
330 | 330 | """Convert json values to objects |
|
331 | 331 | |
|
332 | 332 | We explicitly support converting valid string widget UUIDs to Widget references. |
|
333 | 333 | """ |
|
334 | 334 | if isinstance(x, dict): |
|
335 |
return {k: self._ |
|
|
335 | return {k: self._deserialize_trait(v) for k, v in x.items()} | |
|
336 | 336 | elif isinstance(x, (list, tuple)): |
|
337 |
return [self._ |
|
|
337 | return [self._deserialize_trait(v) for v in x] | |
|
338 | 338 | elif isinstance(x, string_types) and x.startswith('IPY_MODEL_') and x[10:] in Widget.widgets: |
|
339 | 339 | # we want to support having child widgets at any level in a hierarchy |
|
340 | 340 | # trusting that a widget UUID will not appear out in the wild |
General Comments 0
You need to be logged in to leave comments.
Login now