standard model changes

Zachary Sailer 13 years ago committed by MinRK
parent 5af83cd705
commit a219abaeeb

@ -67,6 +67,11 @@ class NamedNotebookHandler(IPythonHandler):
mathjax_url=self.mathjax_url,
)
)
@web.authenticated
def post(self, notebook_path):
nbm =self.notebook_manager
notebook_name = nbm.new_notebook()
class NotebookCopyHandler(IPythonHandler):

@ -6,7 +6,7 @@ Authors:
"""
#-----------------------------------------------------------------------------
# Copyright (C) 2008-2011 The IPython Development Team
# 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.

@ -89,7 +89,7 @@ class FileNotebookManager(NotebookManager):
notebook_names = self.get_notebook_names(path)
notebook_mapping = []
for name in notebook_names:
model = self.notebook_model(name, path)
model = self.notebook_model(name, path, content=False)
notebook_mapping.append(model)
return notebook_mapping

@ -114,13 +114,15 @@ class NotebookManager(LoggingConfigurable):
def notebook_exists(self, notebook_path):
"""Does a notebook exist?"""
def notebook_model(self, notebook_name, notebook_path=None):
def notebook_model(self, notebook_name, notebook_path=None, content=True):
""" Creates the standard notebook model """
last_modified, content = self.read_notebook_object(notebook_name, notebook_path)
last_modified, contents = self.read_notebook_object(notebook_name, notebook_path)
model = {"notebook_name": notebook_name,
"notebook_path": notebook_path,
"content": content,
"last_modified": last_modified.ctime()}
if content == True:
model['content'] = contents
return model
def get_notebook(self, notebook_name, notebook_path=None, format=u'json'):
@ -143,7 +145,7 @@ class NotebookManager(LoggingConfigurable):
raise NotImplementedError('must be implemented in a subclass')
def save_new_notebook(self, data, notebook_path = None, name=None, format=u'json'):
"""Save a new notebook and return its notebook_id.
"""Save a new notebook and return its name.
If a name is passed in, it overrides any values in the notebook data
and the value in the data is updated to use that value.

@ -1,4 +1,4 @@
"""Tornado handlers for the notebooks web service.
"""Tornado handlers for the sessions web service.
Authors:
@ -6,7 +6,7 @@ Authors:
"""
#-----------------------------------------------------------------------------
# Copyright (C) 2008-2011 The IPython Development Team
# 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.

@ -6,7 +6,7 @@ Authors:
"""
#-----------------------------------------------------------------------------
# Copyright (C) 2011 The IPython Development Team
# 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.
@ -53,6 +53,8 @@ class SessionManager(LoggingConfigurable):
notebook_name=notebook_name,
notebook_path=notebook_path,
kernel=kernel)
if notebook_path == None:
model['notebook_path']=""
self.sessions.append(model)
return model

Loading…
Cancel
Save