##// END OF EJS Templates
Fix various review comments
Thomas Kluyver -
Show More
@@ -277,7 +277,7 b' class FileContentsManager(ContentsManager):'
277 Whether to include the contents in the reply
277 Whether to include the contents in the reply
278 type_ : str, optional
278 type_ : str, optional
279 The requested type - 'file', 'notebook', or 'directory'.
279 The requested type - 'file', 'notebook', or 'directory'.
280 Will raise HTTPError 406 if the content doesn't match.
280 Will raise HTTPError 400 if the content doesn't match.
281 format : str, optional
281 format : str, optional
282 The requested format for file contents. 'text' or 'base64'.
282 The requested format for file contents. 'text' or 'base64'.
283 Ignored if this returns a notebook or directory model.
283 Ignored if this returns a notebook or directory model.
@@ -35,7 +35,7 b' class API(object):'
35 def __init__(self, base_url):
35 def __init__(self, base_url):
36 self.base_url = base_url
36 self.base_url = base_url
37
37
38 def _req(self, verb, path, body=None):
38 def _req(self, verb, path, body=None, params=None):
39 response = requests.request(verb,
39 response = requests.request(verb,
40 url_path_join(self.base_url, 'api/contents', path),
40 url_path_join(self.base_url, 'api/contents', path),
41 data=body,
41 data=body,
@@ -47,14 +47,12 b' class API(object):'
47 return self._req('GET', path)
47 return self._req('GET', path)
48
48
49 def read(self, path, type_=None, format=None):
49 def read(self, path, type_=None, format=None):
50 query = []
50 params = {}
51 if type_ is not None:
51 if type_ is not None:
52 query.append('type=' + type_)
52 params['type'] = type_
53 if format is not None:
53 if format is not None:
54 query.append('format=' + format)
54 params['format'] = format
55 if query:
55 return self._req('GET', path, params=params)
56 path += '?' + '&'.join(query)
57 return self._req('GET', path)
58
56
59 def create_untitled(self, path='/', ext='.ipynb'):
57 def create_untitled(self, path='/', ext='.ipynb'):
60 body = None
58 body = None
@@ -87,10 +87,10 b' define(['
87 error : this.create_basic_error_handler(options.error)
87 error : this.create_basic_error_handler(options.error)
88 };
88 };
89 var url = this.api_url(path);
89 var url = this.api_url(path);
90 if (options.type) {
90 params = {};
91 url += '?type=' + options.type;
91 if (options.type) { params.type = options.type; }
92 }
92 if (options.format) { params.format = options.format; }
93 $.ajax(url, settings);
93 $.ajax(url + '?' + $.param(params), settings);
94 };
94 };
95
95
96
96
General Comments 0
You need to be logged in to leave comments. Login now