##// END OF EJS Templates
Adds configuration options to use Google Drive content manager...
Adds configuration options to use Google Drive content manager Adds the key contentmanager_js_source to webapp_settings that allows for specifying the content manager JavaScript source file. Also adds a NotebookManager subclass, ClientSideNotebookManager, which does minimal logic. This class is used when the JavaScript content manager doesn't use the Python notebook manager, but rather implements that logic client side, as is the case for the Google Drive based content manager. A sample command line that uses the Google Drive content manager, and the ClientSideNotebookManager, is ipython notebook --NotebookApp.webapp_settings="{'contentmanager_js_source': 'base/js/drive_contentmanager'}" --NotebookApp.notebook_manager_class="IPython.html.services.notebooks.clientsidenbmanager.ClientSideNotebookManager"

File last commit:

r18552:2143638c
r18639:28c27a69
Show More
handlers.py
56 lines | 1.6 KiB | text/x-python | PythonLexer
"""Tornado handlers for kernel specifications."""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
import json
from tornado import web
from ...base.handlers import IPythonHandler, json_errors
from IPython.kernel.kernelspec import _pythonfirst
class MainKernelSpecHandler(IPythonHandler):
SUPPORTED_METHODS = ('GET',)
@web.authenticated
@json_errors
def get(self):
ksm = self.kernel_spec_manager
results = []
for kernel_name in sorted(ksm.find_kernel_specs(), key=_pythonfirst):
try:
d = ksm.get_kernel_spec(kernel_name).to_dict()
except Exception:
self.log.error("Failed to load kernel spec: '%s'", kernel_name, exc_info=True)
continue
d['name'] = kernel_name
results.append(d)
self.set_header("Content-Type", 'application/json')
self.finish(json.dumps(results))
class KernelSpecHandler(IPythonHandler):
SUPPORTED_METHODS = ('GET',)
@web.authenticated
@json_errors
def get(self, kernel_name):
ksm = self.kernel_spec_manager
try:
kernelspec = ksm.get_kernel_spec(kernel_name)
except KeyError:
raise web.HTTPError(404, u'Kernel spec %s not found' % kernel_name)
self.set_header("Content-Type", 'application/json')
self.finish(kernelspec.to_json())
# URL to handler mappings
kernel_name_regex = r"(?P<kernel_name>\w+)"
default_handlers = [
(r"/api/kernelspecs", MainKernelSpecHandler),
(r"/api/kernelspecs/%s" % kernel_name_regex, KernelSpecHandler),
]