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