removing contents changes from this PR

This commit is contained in:
Paul Ivanov 2013-08-22 15:01:29 -07:00 committed by MinRK
parent 95b505d602
commit f517d44d4b
2 changed files with 6 additions and 95 deletions

View File

@ -66,7 +66,6 @@ from .services.notebooks.nbmanager import NotebookManager
from .services.notebooks.filenbmanager import FileNotebookManager
from .services.clusters.clustermanager import ClusterManager
from .services.sessions.sessionmanager import SessionManager
from .services.contents.contentmanager import ContentManager
from .base.handlers import AuthenticatedFileHandler, FileFindHandler
@ -129,19 +128,19 @@ def load_handlers(name):
class NotebookWebApplication(web.Application):
def __init__(self, ipython_app, kernel_manager, notebook_manager,
cluster_manager, session_manager, content_manager, log,
base_project_url, settings_overrides):
cluster_manager, session_manager, log, base_project_url,
settings_overrides):
settings = self.init_settings(
ipython_app, kernel_manager, notebook_manager, cluster_manager,
session_manager, content_manager, log, base_project_url, settings_overrides)
session_manager, log, base_project_url, settings_overrides)
handlers = self.init_handlers(settings)
super(NotebookWebApplication, self).__init__(handlers, **settings)
def init_settings(self, ipython_app, kernel_manager, notebook_manager,
cluster_manager, session_manager, content_manager, log,
base_project_url, settings_overrides):
cluster_manager, session_manager, log, base_project_url,
settings_overrides):
# Python < 2.6.5 doesn't accept unicode keys in f(**kwargs), and
# base_project_url will always be unicode, which will in turn
# make the patterns unicode, and ultimately result in unicode
@ -171,7 +170,6 @@ class NotebookWebApplication(web.Application):
notebook_manager=notebook_manager,
cluster_manager=cluster_manager,
session_manager=session_manager,
content_manager=content_manager,
# IPython stuff
nbextensions_path = ipython_app.nbextensions_path,
@ -197,7 +195,6 @@ class NotebookWebApplication(web.Application):
handlers.extend(load_handlers('services.notebooks.handlers'))
handlers.extend(load_handlers('services.clusters.handlers'))
handlers.extend(load_handlers('services.sessions.handlers'))
handlers.extend(load_handlers('services.contents.handlers'))
handlers.extend([
(r"/files/(.*)", AuthenticatedFileHandler, {'path' : settings['notebook_manager'].notebook_dir}),
(r"/nbextensions/(.*)", FileFindHandler, {'path' : settings['nbextensions_path']}),
@ -534,7 +531,6 @@ class NotebookApp(BaseIPythonApplication):
self.notebook_manager = kls(parent=self, log=self.log)
self.notebook_manager.load_notebook_names('')
self.session_manager = SessionManager(parent=self, log=self.log)
self.content_manager = ContentManager(parent=self, log=self.log)
self.cluster_manager = ClusterManager(parent=self, log=self.log)
self.cluster_manager.update_profiles()
@ -552,7 +548,7 @@ class NotebookApp(BaseIPythonApplication):
"""initialize tornado webapp and httpserver"""
self.web_app = NotebookWebApplication(
self, self.kernel_manager, self.notebook_manager,
self.cluster_manager, self.session_manager, self.content_manager,
self.cluster_manager, self.session_manager,
self.log, self.base_project_url, self.webapp_settings
)
if self.certfile:

View File

@ -1,85 +0,0 @@
"""Tornado handlers for the contents web service.
Authors:
* Zach Sailer
"""
#-----------------------------------------------------------------------------
# Copyright (C) 2013 The IPython Development Team
#
# 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
from zmq.utils import jsonapi
from IPython.utils.jsonutil import date_default
from ...base.handlers import IPythonHandler
#-----------------------------------------------------------------------------
# Contents web service handlers
#-----------------------------------------------------------------------------
class ContentRootHandler(IPythonHandler):
@web.authenticated
def get(self):
cm = self.content_manager
contents = cm.list_contents("")
self.finish(jsonapi.dumps(contents))
class ContentHandler(IPythonHandler):
@web.authenticated
def get(self, content_path):
cm = self.content_manager
contents = cm.list_contents(content_path)
self.finish(jsonapi.dumps(contents))
@web.authenticated
def delete(self, content_path):
cm = self.content_manager
cm.delete_content(content_path)
self.set_status(204)
self.finish()
class ServicesRedirectHandler(IPythonHandler):
@web.authenticated
def get(self):
url = self.base_project_url + 'api'
self.redirect(url)
class ServicesHandler(IPythonHandler):
@web.authenticated
def get(self):
services = ['contents', 'notebooks', 'sessions', 'kernels', 'clusters']
self.finish(jsonapi.dumps(services))
#-----------------------------------------------------------------------------
# URL to handler mappings
#-----------------------------------------------------------------------------
_content_path_regex = r"(?P<content_path>.+)"
default_handlers = [
(r"api/contents/%s" % _content_path_regex, ContentHandler),
(r"api/contents", ContentRootHandler),
(r"api/", ServicesRedirectHandler),
(r"api", ServicesHandler)
]