Show More
@@ -215,7 +215,7 b' class BaseIPythonApplication(Application):' | |||||
215 | return crashhandler.crash_handler_lite(etype, evalue, tb) |
|
215 | return crashhandler.crash_handler_lite(etype, evalue, tb) | |
216 |
|
216 | |||
217 | def _ipython_dir_changed(self, name, old, new): |
|
217 | def _ipython_dir_changed(self, name, old, new): | |
218 |
if old is not |
|
218 | if old is not Undefined: | |
219 | str_old = py3compat.cast_bytes_py2(os.path.abspath(old), |
|
219 | str_old = py3compat.cast_bytes_py2(os.path.abspath(old), | |
220 | sys.getfilesystemencoding() |
|
220 | sys.getfilesystemencoding() | |
221 | ) |
|
221 | ) |
@@ -355,7 +355,7 b' define(["widgets/js/manager",' | |||||
355 | this.pending_msgs++; |
|
355 | this.pending_msgs++; | |
356 | } |
|
356 | } | |
357 | } |
|
357 | } | |
358 |
// Since the comm is a one-way communication, assume the message |
|
358 | // Since the comm is a one-way communication, assume the message | |
359 | // arrived. Don't call success since we don't have a model back from the server |
|
359 | // arrived. Don't call success since we don't have a model back from the server | |
360 | // this means we miss out on the 'sync' event. |
|
360 | // this means we miss out on the 'sync' event. | |
361 | this._buffered_state_diff = {}; |
|
361 | this._buffered_state_diff = {}; | |
@@ -369,7 +369,7 b' define(["widgets/js/manager",' | |||||
369 | // being the value or the promise of the serialized value |
|
369 | // being the value or the promise of the serialized value | |
370 | var serializers = this.constructor.serializers; |
|
370 | var serializers = this.constructor.serializers; | |
371 | if (serializers) { |
|
371 | if (serializers) { | |
372 | for (k in attrs) { |
|
372 | for (var k in attrs) { | |
373 | if (serializers[k] && serializers[k].serialize) { |
|
373 | if (serializers[k] && serializers[k].serialize) { | |
374 | attrs[k] = (serializers[k].serialize)(attrs[k], this); |
|
374 | attrs[k] = (serializers[k].serialize)(attrs[k], this); | |
375 | } |
|
375 | } | |
@@ -383,11 +383,13 b' define(["widgets/js/manager",' | |||||
383 | for (var i=0; i<keys.length; i++) { |
|
383 | for (var i=0; i<keys.length; i++) { | |
384 | var key = keys[i]; |
|
384 | var key = keys[i]; | |
385 | var value = state[key]; |
|
385 | var value = state[key]; | |
386 |
if (value |
|
386 | if (value) { | |
387 |
|
|
387 | if (value.buffer instanceof ArrayBuffer | |
388 | buffers.push(value); |
|
388 | || value instanceof ArrayBuffer) { | |
389 |
buffer |
|
389 | buffers.push(value); | |
390 |
|
|
390 | buffer_keys.push(key); | |
|
391 | delete state[key]; | |||
|
392 | } | |||
391 | } |
|
393 | } | |
392 | } |
|
394 | } | |
393 | that.comm.send({method: 'backbone', sync_data: state, buffer_keys: buffer_keys}, callbacks, {}, buffers); |
|
395 | that.comm.send({method: 'backbone', sync_data: state, buffer_keys: buffer_keys}, callbacks, {}, buffers); | |
@@ -396,7 +398,7 b' define(["widgets/js/manager",' | |||||
396 | return (utils.reject("Couldn't send widget sync message", true))(error); |
|
398 | return (utils.reject("Couldn't send widget sync message", true))(error); | |
397 | }); |
|
399 | }); | |
398 | }, |
|
400 | }, | |
399 |
|
401 | |||
400 | save_changes: function(callbacks) { |
|
402 | save_changes: function(callbacks) { | |
401 | /** |
|
403 | /** | |
402 | * Push this model's state to the back-end |
|
404 | * Push this model's state to the back-end | |
@@ -410,7 +412,7 b' define(["widgets/js/manager",' | |||||
410 | /** |
|
412 | /** | |
411 | * on_some_change(["key1", "key2"], foo, context) differs from |
|
413 | * on_some_change(["key1", "key2"], foo, context) differs from | |
412 | * on("change:key1 change:key2", foo, context). |
|
414 | * on("change:key1 change:key2", foo, context). | |
413 |
* If the widget attributes key1 and key2 are both modified, |
|
415 | * If the widget attributes key1 and key2 are both modified, | |
414 | * the second form will result in foo being called twice |
|
416 | * the second form will result in foo being called twice | |
415 | * while the first will call foo only once. |
|
417 | * while the first will call foo only once. | |
416 | */ |
|
418 | */ |
@@ -1374,7 +1374,25 b' def test_hold_trait_notifications():' | |||||
1374 | except: |
|
1374 | except: | |
1375 | pass |
|
1375 | pass | |
1376 | nt.assert_equal(t.b, 0) |
|
1376 | nt.assert_equal(t.b, 0) | |
1377 |
|
1377 | |||
|
1378 | ||||
|
1379 | class RollBack(HasTraits): | |||
|
1380 | bar = Int() | |||
|
1381 | def _bar_validate(self, value, trait): | |||
|
1382 | if value: | |||
|
1383 | raise TraitError('foobar') | |||
|
1384 | return value | |||
|
1385 | ||||
|
1386 | ||||
|
1387 | class TestRollback(TestCase): | |||
|
1388 | ||||
|
1389 | def test_roll_back(self): | |||
|
1390 | ||||
|
1391 | def assign_rollback(): | |||
|
1392 | RollBack(bar=1) | |||
|
1393 | ||||
|
1394 | self.assertRaises(TraitError, assign_rollback) | |||
|
1395 | ||||
1378 |
|
1396 | |||
1379 | class OrderTraits(HasTraits): |
|
1397 | class OrderTraits(HasTraits): | |
1380 | notified = Dict() |
|
1398 | notified = Dict() |
@@ -623,7 +623,7 b' class HasTraits(py3compat.with_metaclass(MetaHasTraits, object)):' | |||||
623 | if cache[name][1] is not Undefined: |
|
623 | if cache[name][1] is not Undefined: | |
624 | setattr(self, name, cache[name][1]) |
|
624 | setattr(self, name, cache[name][1]) | |
625 | else: |
|
625 | else: | |
626 |
|
|
626 | self._trait_values.pop(name) | |
627 | cache = {} |
|
627 | cache = {} | |
628 | raise e |
|
628 | raise e | |
629 | finally: |
|
629 | finally: |
General Comments 0
You need to be logged in to leave comments.
Login now