Skip to content

Commit

Permalink
Merge pull request #4099 from michalc/contents_manager_exists_can_ret…
Browse files Browse the repository at this point in the history
…urn_futures

Allow more contents manager functions to return futures
  • Loading branch information
minrk authored Oct 18, 2018
2 parents b663bf1 + 815ed3c commit 9928105
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
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

0 comments on commit 9928105

Please sign in to comment.