From 4ecc06fbf0bc3eb81f2bc879e9a2e478214f4315 2014-11-11 22:46:53 From: Thomas Kluyver Date: 2014-11-11 22:46:53 Subject: [PATCH] Fix various review comments --- diff --git a/IPython/html/services/contents/filemanager.py b/IPython/html/services/contents/filemanager.py index 67af55c..f718d08 100644 --- a/IPython/html/services/contents/filemanager.py +++ b/IPython/html/services/contents/filemanager.py @@ -277,7 +277,7 @@ class FileContentsManager(ContentsManager): Whether to include the contents in the reply type_ : str, optional The requested type - 'file', 'notebook', or 'directory'. - Will raise HTTPError 406 if the content doesn't match. + Will raise HTTPError 400 if the content doesn't match. format : str, optional The requested format for file contents. 'text' or 'base64'. Ignored if this returns a notebook or directory model. diff --git a/IPython/html/services/contents/tests/test_contents_api.py b/IPython/html/services/contents/tests/test_contents_api.py index 5c5b3b9..e49e0bf 100644 --- a/IPython/html/services/contents/tests/test_contents_api.py +++ b/IPython/html/services/contents/tests/test_contents_api.py @@ -35,7 +35,7 @@ class API(object): def __init__(self, base_url): self.base_url = base_url - def _req(self, verb, path, body=None): + def _req(self, verb, path, body=None, params=None): response = requests.request(verb, url_path_join(self.base_url, 'api/contents', path), data=body, @@ -47,14 +47,12 @@ class API(object): return self._req('GET', path) def read(self, path, type_=None, format=None): - query = [] + params = {} if type_ is not None: - query.append('type=' + type_) + params['type'] = type_ if format is not None: - query.append('format=' + format) - if query: - path += '?' + '&'.join(query) - return self._req('GET', path) + params['format'] = format + return self._req('GET', path, params=params) def create_untitled(self, path='/', ext='.ipynb'): body = None diff --git a/IPython/html/static/services/contents.js b/IPython/html/static/services/contents.js index 0d4d7cb..6c7922d 100644 --- a/IPython/html/static/services/contents.js +++ b/IPython/html/static/services/contents.js @@ -87,10 +87,10 @@ define([ error : this.create_basic_error_handler(options.error) }; var url = this.api_url(path); - if (options.type) { - url += '?type=' + options.type; - } - $.ajax(url, settings); + params = {}; + if (options.type) { params.type = options.type; } + if (options.format) { params.format = options.format; } + $.ajax(url + '?' + $.param(params), settings); };