Show More
@@ -309,10 +309,10 b' class FileContentsManager(ContentsManager):' | |||||
309 | """Save the file model and return the model with no content.""" |
|
309 | """Save the file model and return the model with no content.""" | |
310 | path = path.strip('/') |
|
310 | path = path.strip('/') | |
311 |
|
311 | |||
312 | if 'content' not in model: |
|
|||
313 | raise web.HTTPError(400, u'No file content provided') |
|
|||
314 | if 'type' not in model: |
|
312 | if 'type' not in model: | |
315 | raise web.HTTPError(400, u'No file type provided') |
|
313 | raise web.HTTPError(400, u'No file type provided') | |
|
314 | if 'content' not in model and model['type'] != 'directory': | |||
|
315 | raise web.HTTPError(400, u'No file content provided') | |||
316 |
|
316 | |||
317 | # One checkpoint should always exist |
|
317 | # One checkpoint should always exist | |
318 | if self.file_exists(name, path) and not self.list_checkpoints(name, path): |
|
318 | if self.file_exists(name, path) and not self.list_checkpoints(name, path): |
@@ -165,16 +165,16 b' class ContentsManager(LoggingConfigurable):' | |||||
165 | path = path.strip('/') |
|
165 | path = path.strip('/') | |
166 | if model is None: |
|
166 | if model is None: | |
167 | model = {} |
|
167 | model = {} | |
168 | if 'content' not in model: |
|
168 | if 'content' not in model and model.get('type', None) != 'directory': | |
169 | if ext == '.ipynb': |
|
169 | if ext == '.ipynb': | |
170 | metadata = current.new_metadata(name=u'') |
|
170 | metadata = current.new_metadata(name=u'') | |
171 | model['content'] = current.new_notebook(metadata=metadata) |
|
171 | model['content'] = current.new_notebook(metadata=metadata) | |
172 |
model |
|
172 | model['type'] = 'notebook' | |
173 |
model |
|
173 | model['format'] = 'json' | |
174 | else: |
|
174 | else: | |
175 | model['content'] = '' |
|
175 | model['content'] = '' | |
176 |
model |
|
176 | model['type'] = 'file' | |
177 |
model |
|
177 | model['format'] = 'text' | |
178 | if 'name' not in model: |
|
178 | if 'name' not in model: | |
179 | model['name'] = self.increment_filename('Untitled' + ext, path) |
|
179 | model['name'] = self.increment_filename('Untitled' + ext, path) | |
180 |
|
180 | |||
@@ -185,7 +185,7 b' class ContentsManager(LoggingConfigurable):' | |||||
185 | def copy(self, from_name, to_name=None, path=''): |
|
185 | def copy(self, from_name, to_name=None, path=''): | |
186 | """Copy an existing file and return its new model. |
|
186 | """Copy an existing file and return its new model. | |
187 |
|
187 | |||
188 |
If to_name not specified, increment `from_name-Copy#. |
|
188 | If to_name not specified, increment `from_name-Copy#.ext`. | |
189 | """ |
|
189 | """ | |
190 | path = path.strip('/') |
|
190 | path = path.strip('/') | |
191 | model = self.get_model(from_name, path) |
|
191 | model = self.get_model(from_name, path) |
General Comments 0
You need to be logged in to leave comments.
Login now