##// END OF EJS Templates
Fixed order of notebook loading and kernel starting....
Brian Granger -
Show More
@@ -16,7 +16,9 b' var IPython = (function (IPython) {'
16 var key = IPython.utils.keycodes;
16 var key = IPython.utils.keycodes;
17
17
18 var CodeCell = function (kernel) {
18 var CodeCell = function (kernel) {
19 this.kernel = kernel;
19 // The kernel doesn't have to be set at creation time, in that case
20 // it will be null and set_kernel has to be called later.
21 this.kernel = kernel || null;
20 this.code_mirror = null;
22 this.code_mirror = null;
21 this.input_prompt_number = null;
23 this.input_prompt_number = null;
22 this.tooltip_on_tab = true;
24 this.tooltip_on_tab = true;
@@ -48,7 +50,7 b' var IPython = (function (IPython) {'
48
50
49 // construct a completer only if class exist
51 // construct a completer only if class exist
50 // otherwise no print view
52 // otherwise no print view
51 if (IPython.Completer != undefined )
53 if (IPython.Completer !== undefined)
52 {
54 {
53 this.completer = new IPython.Completer(this);
55 this.completer = new IPython.Completer(this);
54 }
56 }
@@ -140,8 +142,14 b' var IPython = (function (IPython) {'
140 return false;
142 return false;
141 };
143 };
142
144
145
143 // Kernel related calls.
146 // Kernel related calls.
144
147
148 CodeCell.prototype.set_kernel = function (kernel) {
149 this.kernel = kernel;
150 }
151
152
145 CodeCell.prototype.execute = function () {
153 CodeCell.prototype.execute = function () {
146 this.output_area.clear_output(true, true, true);
154 this.output_area.clear_output(true, true, true);
147 this.set_input_prompt('*');
155 this.set_input_prompt('*');
@@ -888,6 +888,14 b' var IPython = (function (IPython) {'
888 var base_url = $('body').data('baseKernelUrl') + "kernels";
888 var base_url = $('body').data('baseKernelUrl') + "kernels";
889 this.kernel = new IPython.Kernel(base_url);
889 this.kernel = new IPython.Kernel(base_url);
890 this.kernel.start(this.notebook_id);
890 this.kernel.start(this.notebook_id);
891 // Now that the kernel has been created, tell the CodeCells about it.
892 var ncells = this.ncells();
893 for (var i=0; i<ncells; i++) {
894 var cell = this.get_cell(i);
895 if (cell instanceof IPython.CodeCell) {
896 cell.set_kernel(this.kernel)
897 };
898 };
891 };
899 };
892
900
893
901
@@ -1076,10 +1084,6 b' var IPython = (function (IPython) {'
1076
1084
1077
1085
1078 Notebook.prototype.load_notebook_success = function (data, status, xhr) {
1086 Notebook.prototype.load_notebook_success = function (data, status, xhr) {
1079 // Create the kernel before creating cells as they need to be passed it.
1080 if (! this.read_only) {
1081 this.start_kernel();
1082 }
1083 this.fromJSON(data);
1087 this.fromJSON(data);
1084 if (this.ncells() === 0) {
1088 if (this.ncells() === 0) {
1085 this.insert_cell_below('code');
1089 this.insert_cell_below('code');
@@ -1111,6 +1115,11 b' var IPython = (function (IPython) {'
1111 width: 400
1115 width: 400
1112 });
1116 });
1113 }
1117 }
1118 // Create the kernel after the notebook is completely loaded to prevent
1119 // code execution upon loading, which is a security risk.
1120 if (! this.read_only) {
1121 this.start_kernel();
1122 }
1114 $([IPython.events]).trigger('notebook_loaded.Notebook');
1123 $([IPython.events]).trigger('notebook_loaded.Notebook');
1115 };
1124 };
1116
1125
General Comments 0
You need to be logged in to leave comments. Login now