Download '.py' fixed, deleted debugging output

This commit is contained in:
Zachary Sailer 2013-07-12 17:08:47 -07:00 committed by MinRK
parent bfff3d817d
commit 022b8324b2
3 changed files with 6 additions and 9 deletions

View File

@ -22,7 +22,6 @@ HTTPError = web.HTTPError
from ..base.handlers import IPythonHandler
from ..utils import url_path_join
from urllib import quote
#-----------------------------------------------------------------------------
# Handlers
@ -51,9 +50,6 @@ class NamedNotebookHandler(IPythonHandler):
def get(self, notebook_path):
nbm = self.notebook_manager
name, path = nbm.named_notebook_path(notebook_path)
if name != None:
name = quote(name)
self.log.info(name)
if path == None:
project = self.project + '/' + name
else:

View File

@ -70,7 +70,7 @@ class NotebookHandler(IPythonHandler):
else:
format = self.get_argument('format', default='json')
model = nbm.notebook_model(name,path)
data, name = nbm.get_notebook(model, format)
last_mod, representation, name = nbm.get_notebook(name, path, format)
if format == u'json':
self.set_header('Content-Type', 'application/json')

View File

@ -117,19 +117,20 @@ class NotebookManager(LoggingConfigurable):
"content": content}
return model
def get_notebook(self, body, format=u'json'):
def get_notebook(self, notebook_name, notebook_path=None, format=u'json'):
"""Get the representation of a notebook in format by notebook_name."""
format = unicode(format)
if format not in self.allowed_formats:
raise web.HTTPError(415, u'Invalid notebook format: %s' % format)
kwargs = {}
last_mod, nb = self.read_notebook_object(notebook_name, notebook_path)
if format == 'json':
# don't split lines for sending over the wire, because it
# should match the Python in-memory format.
kwargs['split_lines'] = False
representation = current.writes(body, format, **kwargs)
name = body['content']['metadata']['name']
return representation, name
representation = current.writes(nb, format, **kwargs)
name = nb.metadata.get('name', 'notebook')
return last_mod, representation, name
def read_notebook_object(self, notebook_name, notebook_path):
"""Get the object representation of a notebook by notebook_id."""