##// END OF EJS Templates
bash completion: ipython <tab> shows only subcmds...
bash completion: ipython <tab> shows only subcmds If a partial filename, or an flag or option argument is invoked, those completions will still take place, but by default, to aid the user in the discovery of subcommands, pressing tab immediately after ipython will list *only* the subcommands as possible completions

File last commit:

r13398:da0c6c29
r13569:53c89a60
Show More
handlers.py
79 lines | 2.8 KiB | text/x-python | PythonLexer
Brian E. Granger
Splitting handlers into different files....
r10642 """Tornado handlers for the live notebook view.
Brian E. Granger
Adding new files.
r10641
Authors:
* Brian Granger
"""
#-----------------------------------------------------------------------------
Brian E. Granger
Splitting handlers into different files....
r10642 # Copyright (C) 2011 The IPython Development Team
Brian E. Granger
Adding new files.
r10641 #
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING, distributed as part of this software.
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------
from tornado import web
Brian E. Granger
Splitting handlers into different files....
r10642 HTTPError = web.HTTPError
Brian E. Granger
Adding new files.
r10641
MinRK
remove notebook read-only view...
r11644 from ..base.handlers import IPythonHandler
MinRK
adjust definition of 'path' in notebooks...
r13067 from ..services.notebooks.handlers import _notebook_path_regex, _path_regex
Thomas Kluyver
Remove unused imports in IPython.html.notebook.handlers
r13398 from ..utils import url_path_join, url_escape
Brian E. Granger
Adding new files.
r10641
#-----------------------------------------------------------------------------
Brian E. Granger
Splitting handlers into different files....
r10642 # Handlers
Brian E. Granger
Adding new files.
r10641 #-----------------------------------------------------------------------------
Zachary Sailer
removed '/new' URL and added POST notebook request
r13016 class NotebookHandler(IPythonHandler):
Brian E. Granger
Adding new files.
r10641
@web.authenticated
MinRK
adjust definition of 'path' in notebooks...
r13067 def get(self, path='', name=None):
Paul Ivanov
named_notebook_path: consistent usage convention
r13029 """get renders the notebook template if a name is given, or
redirects to the '/files/' handler if the name is not given."""
MinRK
strip '/' from paths in template-render handlers
r13117 path = path.strip('/')
Brian E. Granger
Adding new files.
r10641 nbm = self.notebook_manager
MinRK
adjust definition of 'path' in notebooks...
r13067 if name is None:
MinRK
cleanup old, unused `/notebooks/foo` API methods...
r13073 raise web.HTTPError(500, "This shouldn't be accessible: %s" % self.request.uri)
MinRK
adjust definition of 'path' in notebooks...
r13067 # a .ipynb filename was given
if not nbm.notebook_exists(name, path):
raise web.HTTPError(404, u'Notebook does not exist: %s/%s' % (path, name))
MinRK
move url_[un]escape to utils from nbm
r13068 name = url_escape(name)
path = url_escape(path)
MinRK
adjust definition of 'path' in notebooks...
r13067 self.write(self.render_template('notebook.html',
project=self.project_dir,
notebook_path=path,
notebook_name=name,
kill_kernel=False,
mathjax_url=self.mathjax_url,
)
)
Zachary Sailer
removed '/new' URL and added POST notebook request
r13016
MinRK
cleanup old, unused `/notebooks/foo` API methods...
r13073 class NotebookRedirectHandler(IPythonHandler):
def get(self, path=''):
Zachary Sailer
Change new/copy URLS to POST requests
r13017 nbm = self.notebook_manager
MinRK
cleanup old, unused `/notebooks/foo` API methods...
r13073 if nbm.path_exists(path):
# it's a *directory*, redirect to /tree
url = url_path_join(self.base_project_url, 'tree', path)
Paul Ivanov
named_notebook_path: consistent usage convention
r13029 else:
MinRK
cleanup old, unused `/notebooks/foo` API methods...
r13073 # otherwise, redirect to /files
# TODO: This should check if it's actually a file
url = url_path_join(self.base_project_url, 'files', path)
MinRK
url_escape redirects
r13135 url = url_escape(url)
self.log.debug("Redirecting %s to %s", self.request.path, url)
MinRK
cleanup old, unused `/notebooks/foo` API methods...
r13073 self.redirect(url)
Brian E. Granger
Adding new files.
r10641
Brian E. Granger
More work on the handlers
r10647 #-----------------------------------------------------------------------------
# URL to handler mappings
#-----------------------------------------------------------------------------
default_handlers = [
MinRK
simplify handler patterns...
r13079 (r"/notebooks%s" % _notebook_path_regex, NotebookHandler),
(r"/notebooks%s" % _path_regex, NotebookRedirectHandler),
Zachary Sailer
fixing broken links from recent changes....
r13033 ]