##// END OF EJS Templates
fix clientside notebook manager and assume tree is dir by default...
Matthias Bussonnier -
Show More
@@ -13,8 +13,8 class ClientSideContentsManager(ContentsManager):
13 this class as the contents manager allows those pages to render without
13 this class as the contents manager allows those pages to render without
14 checking something that the server doesn't know about.
14 checking something that the server doesn't know about.
15 """
15 """
16 def path_exists(self, path):
16 def dir_exists(self, path):
17 return True
17 return True
18
18
19 def is_hidden(self, path):
19 def is_hidden(self, path):
20 return False
20 return False
@@ -36,21 +36,8 class TreeHandler(IPythonHandler):
36 def get(self, path=''):
36 def get(self, path=''):
37 path = path.strip('/')
37 path = path.strip('/')
38 cm = self.contents_manager
38 cm = self.contents_manager
39 if cm.file_exists(path):
39 if cm.dir_exists(path=path):
40 # it's not a directory, we have redirecting to do
40 if cm.is_hidden(path):
41 model = cm.get(path, content=False)
42 # redirect to /api/notebooks if it's a notebook, otherwise /api/files
43 service = 'notebooks' if model['type'] == 'notebook' else 'files'
44 url = url_escape(url_path_join(
45 self.base_url, service, path,
46 ))
47 self.log.debug("Redirecting %s to %s", self.request.path, url)
48 self.redirect(url)
49 else:
50 if not cm.dir_exists(path=path):
51 # Directory is hidden or does not exist.
52 raise web.HTTPError(404)
53 elif cm.is_hidden(path):
54 self.log.info("Refusing to serve hidden directory, via 404 Error")
41 self.log.info("Refusing to serve hidden directory, via 404 Error")
55 raise web.HTTPError(404)
42 raise web.HTTPError(404)
56 breadcrumbs = self.generate_breadcrumbs(path)
43 breadcrumbs = self.generate_breadcrumbs(path)
@@ -61,6 +48,18 class TreeHandler(IPythonHandler):
61 breadcrumbs=breadcrumbs,
48 breadcrumbs=breadcrumbs,
62 terminals_available=self.settings['terminals_available'],
49 terminals_available=self.settings['terminals_available'],
63 ))
50 ))
51 elif cm.file_exists(path):
52 # it's not a directory, we have redirecting to do
53 model = cm.get(path, content=False)
54 # redirect to /api/notebooks if it's a notebook, otherwise /api/files
55 service = 'notebooks' if model['type'] == 'notebook' else 'files'
56 url = url_escape(url_path_join(
57 self.base_url, service, path,
58 ))
59 self.log.debug("Redirecting %s to %s", self.request.path, url)
60 self.redirect(url)
61 else:
62 raise web.HTTPError(404)
64
63
65
64
66 #-----------------------------------------------------------------------------
65 #-----------------------------------------------------------------------------
General Comments 0
You need to be logged in to leave comments. Login now