Merge pull request #4099 from michalc/contents_manager_exists_can_return_futures

Allow more contents manager functions to return futures
pull/4120/head
Min RK 8 years ago committed by GitHub
commit 9928105052
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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)

@ -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()

Loading…
Cancel
Save