diff --git a/notebook/files/handlers.py b/notebook/files/handlers.py index 7973fd6914..1da0ad71d4 100644 --- a/notebook/files/handlers.py +++ b/notebook/files/handlers.py @@ -12,7 +12,7 @@ from base64 import decodestring as decodebytes -from tornado import web +from tornado import gen, web from notebook.base.handlers import IPythonHandler @@ -51,7 +51,7 @@ def get(self, path, include_body=True): else: name = path - model = cm.get(path, type='file', content=include_body) + model = yield gen.maybe_future(cm.get(path, type='file', content=include_body)) if self.get_argument("download", False): self.set_attachment_header(name) diff --git a/notebook/services/contents/handlers.py b/notebook/services/contents/handlers.py index 25dcaf213c..8756ae60c5 100644 --- a/notebook/services/contents/handlers.py +++ b/notebook/services/contents/handlers.py @@ -182,10 +182,12 @@ def post(self, path=''): cm = self.contents_manager - if cm.file_exists(path): + file_exists = yield gen.maybe_future(cm.file_exists(path)) + if file_exists: raise web.HTTPError(400, "Cannot POST to files, use PUT instead.") - if not cm.dir_exists(path): + dir_exists = yield gen.maybe_future(cm.dir_exists(path)) + if not dir_exists: raise web.HTTPError(404, "No such directory: %s" % path) model = self.get_json_body()