From 1dd8c69b816c2f385b3ef037590a73a1d2fb5ab2 2013-10-17 21:09:17 From: Thomas Kluyver Date: 2013-10-17 21:09:17 Subject: [PATCH] Fix some HTTP status codes in sessions API --- diff --git a/IPython/html/services/sessions/handlers.py b/IPython/html/services/sessions/handlers.py index 081d64e..b194ca6 100644 --- a/IPython/html/services/sessions/handlers.py +++ b/IPython/html/services/sessions/handlers.py @@ -63,6 +63,7 @@ class SessionRootHandler(IPythonHandler): kernel_id = km.start_kernel(cwd=nbm.notebook_dir) model = sm.create_session(name=name, path=path, kernel_id=kernel_id, ws_url=self.ws_url) self.set_header('Location', '{0}/api/sessions/{1}'.format(self.base_project_url, model['id'])) + self.set_status(201) self.finish(json.dumps(model, default=date_default)) class SessionHandler(IPythonHandler): diff --git a/IPython/html/services/sessions/sessionmanager.py b/IPython/html/services/sessions/sessionmanager.py index b85f0a7..ffec398 100644 --- a/IPython/html/services/sessions/sessionmanager.py +++ b/IPython/html/services/sessions/sessionmanager.py @@ -133,7 +133,7 @@ class SessionManager(LoggingConfigurable): if reply is not None: model = self.reply_to_dictionary_model(reply) else: - model = None + raise web.HTTPError(404, u'Session not found: %s=%r' % (column, value)) return model def update_session(self, session_id, **kwargs): @@ -151,8 +151,6 @@ class SessionManager(LoggingConfigurable): and the value replaces the current value in the session with session_id. """ - column = kwargs.keys() # uses only the first kwarg that is entered - value = kwargs.values() for kwarg in kwargs: try: self.cursor.execute("UPDATE session SET %s=? WHERE id=?" %kwarg, (kwargs[kwarg], session_id))