Merge pull request #6568 from minrk/remember-kernel

Make default kernel configurable
This commit is contained in:
Matthias Bussonnier 2014-09-30 16:49:00 +02:00
commit a940971866
4 changed files with 8 additions and 29 deletions

View File

@ -45,7 +45,8 @@ class SessionRootHandler(IPythonHandler):
try:
kernel_name = model['kernel']['name']
except KeyError:
raise web.HTTPError(400, "Missing field in JSON data: kernel.name")
self.log.debug("No kernel name specified, using default kernel")
kernel_name = None
# Check to see if session exists
if sm.session_exists(name=name, path=path):

View File

@ -1,20 +1,7 @@
"""A base class session manager.
"""A base class session manager."""
Authors:
* Zach Sailer
"""
#-----------------------------------------------------------------------------
# Copyright (C) 2013 The IPython Development Team
#
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING, distributed as part of this software.
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
import uuid
import sqlite3
@ -25,9 +12,6 @@ from IPython.config.configurable import LoggingConfigurable
from IPython.utils.py3compat import unicode_type
from IPython.utils.traitlets import Instance
#-----------------------------------------------------------------------------
# Classes
#-----------------------------------------------------------------------------
class SessionManager(LoggingConfigurable):
@ -73,7 +57,7 @@ class SessionManager(LoggingConfigurable):
"Create a uuid for a new session"
return unicode_type(uuid.uuid4())
def create_session(self, name=None, path=None, kernel_name='python'):
def create_session(self, name=None, path=None, kernel_name=None):
"""Creates a session and returns its model"""
session_id = self.new_session_id()
# allow nbm to specify kernels cwd

View File

@ -12,7 +12,7 @@ define([
this.selector = selector;
this.notebook = notebook;
this.events = notebook.events;
this.current_selection = notebook.default_kernel_name;
this.current_selection = null;
this.kernelspecs = {};
if (this.selector !== undefined) {
this.element = $(selector);

View File

@ -70,9 +70,6 @@ define([
// Create default scroll manager.
this.scroll_manager = new scrollmanager.ScrollManager(this);
// default_kernel_name is a temporary measure while we implement proper
// kernel selection and delayed start. Do not rely on it.
this.default_kernel_name = 'python';
// TODO: This code smells (and the other `= this` line a couple lines down)
// We need a better way to deal with circular instance references.
this.keyboard_manager.notebook = this;
@ -1563,9 +1560,6 @@ define([
*/
Notebook.prototype.start_session = function (kernel_name) {
var that = this;
if (kernel_name === undefined) {
kernel_name = this.default_kernel_name;
}
if (this._session_starting) {
throw new session.SessionAlreadyStarting();
}
@ -2330,7 +2324,7 @@ define([
// code execution upon loading, which is a security risk.
if (this.session === null) {
var kernelspec = this.metadata.kernelspec || {};
var kernel_name = kernelspec.name || this.default_kernel_name;
var kernel_name = kernelspec.name;
this.start_session(kernel_name);
}