From ba358e322554fefdb934bebc597ce9844c91e474 2013-05-02 00:32:46 From: MinRK Date: 2013-05-02 00:32:46 Subject: [PATCH] fix Location headers --- diff --git a/IPython/frontend/html/notebook/handlers.py b/IPython/frontend/html/notebook/handlers.py index b0aef89..32ec552 100644 --- a/IPython/frontend/html/notebook/handlers.py +++ b/IPython/frontend/html/notebook/handlers.py @@ -399,7 +399,7 @@ class MainKernelHandler(IPythonHandler): notebook_id = self.get_argument('notebook', default=None) kernel_id = km.start_kernel(notebook_id, cwd=nbm.notebook_dir) data = {'ws_url':self.ws_url,'kernel_id':kernel_id} - self.set_header('Location', '/'+kernel_id) + self.set_header('Location', '{0}kernels/{1}'.format(self.base_kernel_url, kernel_id)) self.finish(jsonapi.dumps(data)) @@ -426,7 +426,7 @@ class KernelActionHandler(IPythonHandler): if action == 'restart': km.restart_kernel(kernel_id) data = {'ws_url':self.ws_url, 'kernel_id':kernel_id} - self.set_header('Location', '/'+kernel_id) + self.set_header('Location', '{0}kernels/{1}'.format(self.base_kernel_url, kernel_id)) self.write(jsonapi.dumps(data)) self.finish() @@ -641,7 +641,7 @@ class NotebookRootHandler(IPythonHandler): notebook_id = nbm.save_new_notebook(body, name=name, format=format) else: notebook_id = nbm.new_notebook() - self.set_header('Location', '/'+notebook_id) + self.set_header('Location', '{0}notebooks/{1}'.format(self.base_project_url, notebook_id)) self.finish(jsonapi.dumps(notebook_id)) @@ -698,6 +698,9 @@ class NotebookCheckpointsHandler(IPythonHandler): nbm = self.notebook_manager checkpoint = nbm.create_checkpoint(notebook_id) data = jsonapi.dumps(checkpoint, default=date_default) + self.set_header('Location', '{0}notebooks/{1}/checkpoints/{2}'.format( + self.base_project_url, notebook_id, checkpoint['checkpoint_id'] + )) self.finish(data)