Show More
@@ -22,7 +22,6 b' HTTPError = web.HTTPError' | |||
|
22 | 22 | |
|
23 | 23 | from ..base.handlers import IPythonHandler |
|
24 | 24 | from ..utils import url_path_join |
|
25 | from urllib import quote | |
|
26 | 25 | |
|
27 | 26 | #----------------------------------------------------------------------------- |
|
28 | 27 | # Handlers |
@@ -51,9 +50,6 b' class NamedNotebookHandler(IPythonHandler):' | |||
|
51 | 50 | def get(self, notebook_path): |
|
52 | 51 | nbm = self.notebook_manager |
|
53 | 52 | name, path = nbm.named_notebook_path(notebook_path) |
|
54 | if name != None: | |
|
55 | name = quote(name) | |
|
56 | self.log.info(name) | |
|
57 | 53 | if path == None: |
|
58 | 54 | project = self.project + '/' + name |
|
59 | 55 | else: |
@@ -70,7 +70,7 b' class NotebookHandler(IPythonHandler):' | |||
|
70 | 70 | else: |
|
71 | 71 | format = self.get_argument('format', default='json') |
|
72 | 72 | model = nbm.notebook_model(name,path) |
|
73 |
|
|
|
73 | last_mod, representation, name = nbm.get_notebook(name, path, format) | |
|
74 | 74 | |
|
75 | 75 | if format == u'json': |
|
76 | 76 | self.set_header('Content-Type', 'application/json') |
@@ -117,19 +117,20 b' class NotebookManager(LoggingConfigurable):' | |||
|
117 | 117 | "content": content} |
|
118 | 118 | return model |
|
119 | 119 | |
|
120 |
def get_notebook(self, |
|
|
120 | def get_notebook(self, notebook_name, notebook_path=None, format=u'json'): | |
|
121 | 121 | """Get the representation of a notebook in format by notebook_name.""" |
|
122 | 122 | format = unicode(format) |
|
123 | 123 | if format not in self.allowed_formats: |
|
124 | 124 | raise web.HTTPError(415, u'Invalid notebook format: %s' % format) |
|
125 | 125 | kwargs = {} |
|
126 | last_mod, nb = self.read_notebook_object(notebook_name, notebook_path) | |
|
126 | 127 | if format == 'json': |
|
127 | 128 | # don't split lines for sending over the wire, because it |
|
128 | 129 | # should match the Python in-memory format. |
|
129 | 130 | kwargs['split_lines'] = False |
|
130 |
representation = current.writes(b |
|
|
131 |
name = |
|
|
132 | return representation, name | |
|
131 | representation = current.writes(nb, format, **kwargs) | |
|
132 | name = nb.metadata.get('name', 'notebook') | |
|
133 | return last_mod, representation, name | |
|
133 | 134 | |
|
134 | 135 | def read_notebook_object(self, notebook_name, notebook_path): |
|
135 | 136 | """Get the object representation of a notebook by notebook_id.""" |
General Comments 0
You need to be logged in to leave comments.
Login now