Show More
@@ -464,7 +464,13 b' class TrailingSlashHandler(web.RequestHandler):' | |||
|
464 | 464 | |
|
465 | 465 | class FilesRedirectHandler(IPythonHandler): |
|
466 | 466 | """Handler for redirecting relative URLs to the /files/ handler""" |
|
467 | def get(self, path=''): | |
|
467 | ||
|
468 | @staticmethod | |
|
469 | def redirect_to_files(self, path): | |
|
470 | """make redirect logic a reusable static method | |
|
471 | ||
|
472 | so it can be called from other handlers. | |
|
473 | """ | |
|
468 | 474 | cm = self.contents_manager |
|
469 | 475 | if cm.dir_exists(path): |
|
470 | 476 | # it's a *directory*, redirect to /tree |
@@ -488,6 +494,9 b' class FilesRedirectHandler(IPythonHandler):' | |||
|
488 | 494 | url = url_escape(url) |
|
489 | 495 | self.log.debug("Redirecting %s to %s", self.request.path, url) |
|
490 | 496 | self.redirect(url) |
|
497 | ||
|
498 | def get(self, path=''): | |
|
499 | return self.redirect_to_files(self, path) | |
|
491 | 500 | |
|
492 | 501 | |
|
493 | 502 | #----------------------------------------------------------------------------- |
@@ -28,12 +28,12 b' class NotebookHandler(IPythonHandler):' | |||
|
28 | 28 | except web.HTTPError as e: |
|
29 | 29 | if e.status_code == 404 and 'files' in path.split('/'): |
|
30 | 30 | # 404, but '/files/' in URL, let FilesRedirect take care of it |
|
31 |
return FilesRedirectHandler. |
|
|
31 | return FilesRedirectHandler.redirect_to_files(self, path) | |
|
32 | 32 | else: |
|
33 | 33 | raise |
|
34 | 34 | if model['type'] != 'notebook': |
|
35 | 35 | # not a notebook, redirect to files |
|
36 |
return FilesRedirectHandler. |
|
|
36 | return FilesRedirectHandler.redirect_to_files(self, path) | |
|
37 | 37 | name = url_escape(path.rsplit('/', 1)[-1]) |
|
38 | 38 | path = url_escape(path) |
|
39 | 39 | self.write(self.render_template('notebook.html', |
General Comments 0
You need to be logged in to leave comments.
Login now