diff --git a/notebook/files/handlers.py b/notebook/files/handlers.py index 7973fd691..1da0ad71d 100644 --- a/notebook/files/handlers.py +++ b/notebook/files/handlers.py @@ -12,7 +12,7 @@ except ImportError: #PY2 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 @@ class FilesHandler(IPythonHandler): 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 25dcaf213..8756ae60c 100644 --- a/notebook/services/contents/handlers.py +++ b/notebook/services/contents/handlers.py @@ -182,10 +182,12 @@ class ContentsHandler(APIHandler): 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()