Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow more contents manager functions to return futures #4099

Merged
merged 1 commit into from
Oct 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions notebook/files/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down
6 changes: 4 additions & 2 deletions notebook/services/contents/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down