change standard money keys

pull/37/head
Zachary Sailer 13 years ago committed by MinRK
parent c7375e170f
commit 8261ac2cb9

@ -53,6 +53,20 @@ class ContentHandler(IPythonHandler):
self.set_status(204)
self.finish()
class ServicesRedirectHandler(IPythonHandler):
@web.authenticated
def get(self):
url = self.base_project_url + 'api'
self.redirect(url)
class ServicesHandler(IPythonHandler):
@web.authenticated
def get(self):
services = ['contents', 'notebooks', 'sessions', 'kernels', 'clusters']
self.finish(jsonapi.dumps(services))
#-----------------------------------------------------------------------------
# URL to handler mappings
@ -62,7 +76,10 @@ _content_path_regex = r"(?P<content_path>.+)"
default_handlers = [
(r"api/contents/%s" % _content_path_regex, ContentHandler),
(r"api/contents", ContentRootHandler)
(r"api/contents", ContentRootHandler),
(r"api/", ServicesRedirectHandler),
(r"api", ServicesHandler)
]

@ -76,13 +76,13 @@ class MappingKernelManager(MultiKernelManager):
"""Shutdown a kernel by kernel_id"""
i = 0
for kernel in self.kernels:
if kernel['kernel_id'] == kernel_id:
if kernel['id'] == kernel_id:
del self.kernels[i]
i = i+1
super(MappingKernelManager, self).shutdown_kernel(kernel_id, now=now)
def kernel_model(self, kernel_id, ws_url):
model = {"kernel_id":kernel_id, "ws_url": ws_url}
model = {"id":kernel_id, "ws_url": ws_url}
self.kernels.append(model)
return model

@ -135,9 +135,9 @@ class NotebookManager(LoggingConfigurable):
def notebook_model(self, notebook_name, notebook_path=None, content=True):
""" Creates the standard notebook model """
last_modified, contents = self.read_notebook_object(notebook_name, notebook_path)
model = {"notebook_name": notebook_name,
"notebook_path": notebook_path,
"last_modified": last_modified.ctime()}
model = {"name": notebook_name,
"path": notebook_path,
"last_modified (UTC)": last_modified.ctime()}
if content == True:
model['content'] = contents
return model

@ -38,8 +38,8 @@ class SessionManager(LoggingConfigurable):
"""Get an existing session or create a new one"""
model = None
for session in self.sessions:
if session['notebook_name'] == nb_name and session['notebook_path'] == nb_path:
session_id = session['session_id']
if session['name'] == nb_name and session['path'] == nb_path:
session_id = session['id']
model = session
if model != None:
return session_id, model
@ -49,12 +49,12 @@ class SessionManager(LoggingConfigurable):
def session_model(self, session_id, notebook_name=None, notebook_path=None, kernel=None):
""" Create a session that links notebooks with kernels """
model = dict(session_id=session_id,
notebook_name=notebook_name,
notebook_path=notebook_path,
model = dict(id=session_id,
name=notebook_name,
path=notebook_path,
kernel=kernel)
if notebook_path == None:
model['notebook_path']=""
model['path']=""
self.sessions.append(model)
return model
@ -65,33 +65,33 @@ class SessionManager(LoggingConfigurable):
def set_kernel_for_sessions(self, session_id, kernel_id):
"""Maps the kernel_ids to the session_id in session_mapping"""
for session in self.sessions:
if session['session_id'] == session_id:
session['kernel_id'] = kernel_id
if session['id'] == session_id:
session['kernel']['id'] = kernel_id
return self.sessions
def delete_mapping_for_session(self, session_id):
"""Delete the session from session_mapping with the given session_id"""
i = 0
for session in self.sessions:
if session['session_id'] == session_id:
if session['id'] == session_id:
del self.sessions[i]
i = i + 1
return self.sessions
def get_session_from_id(self, session_id):
for session in self.sessions:
if session['session_id'] == session_id:
if session['id'] == session_id:
return session
def get_notebook_from_session(self, session_id):
"""Returns the notebook_path for the given session_id"""
for session in self.sessions:
if session['session_id'] == session_id:
return session['notebook_name']
if session['id'] == session_id:
return session['name']
def get_kernel_from_session(self, session_id):
"""Returns the kernel_id for the given session_id"""
for session in self.sessions:
if session['session_id'] == session_id:
return session['kernel']['kernel_id']
if session['id'] == session_id:
return session['kernel']['id']

@ -1519,16 +1519,6 @@ var IPython = (function (IPython) {
// Persistance and loading
/**
* Getter method for this notebook's ID.
*
* @method get_notebook_id
* @return {String} This notebook's ID
*/
Notebook.prototype.get_notebook_id = function () {
return this.notebook_id;
};
/**
* Getter method for this notebook's name.
*
@ -1757,7 +1747,7 @@ var IPython = (function (IPython) {
Notebook.prototype.notebook_rename = function (nbname) {
var that = this;
var new_name = nbname + '.ipynb'
var name = {'notebook_name': new_name};
var name = {'name': new_name};
var settings = {
processData : false,
cache : false,
@ -1774,7 +1764,7 @@ var IPython = (function (IPython) {
Notebook.prototype.rename_success = function (json, status, xhr) {
this.notebook_name = json.notebook_name
this.notebook_name = json.name
var notebook_path = this.notebookPath() + this.notebook_name;
this.session.notebook_rename(notebook_path);
$([IPython.events]).trigger('notebook_renamed.Notebook');

@ -110,9 +110,9 @@ var IPython = (function (IPython) {
Kernel.prototype._kernel_started = function (json) {
console.log("Kernel started: ", json.kernel_id);
console.log("Kernel started: ", json.id);
this.running = true;
this.kernel_id = json.kernel_id;
this.kernel_id = json.id;
var ws_url = json.ws_url;
if (ws_url.match(/wss?:\/\//) == null) {
// trailing 's' in https will become wss for secure web sockets

@ -62,7 +62,7 @@ var IPython = (function (IPython) {
* @method start_kernel
*/
Session.prototype.start_kernel = function (json) {
this.session_id = json.session_id;
this.session_id = json.id;
this.kernel_content = json.kernel;
var base_url = $('body').data('baseKernelUrl') + "api/kernels";
this.kernel = new IPython.Kernel(base_url, this.session_id);

@ -122,13 +122,13 @@ var IPython = (function (IPython) {
var len = data.length;
if (len != 0) {
for (var i=0; i<len; i++) {
if (data[i]['notebook_path']==null) {
nb_path = data[i]['notebook_name'];
if (data[i]['path']==null) {
nb_path = data[i]['name'];
}
else {
nb_path = data[i]['notebook_path'] + data[i]['notebook_name'];
nb_path = data[i]['path'] + data[i]['name'];
}
this.sessions[nb_path]= data[i]['session_id'];
this.sessions[nb_path]= data[i]['id'];
}
};
this.load_list();
@ -168,7 +168,7 @@ var IPython = (function (IPython) {
)
}
for (var i=0; i<len; i++) {
var name = data[i].notebook_name;
var name = data[i].name;
var path = this.notebookPath();
var nbname = name.split(".")[0];
var item = this.new_notebook_item(i);

Loading…
Cancel
Save