From 9bd8102b0a7740a01c0bed625b927eba63aa5bc2 Mon Sep 17 00:00:00 2001 From: Davide Setti Date: Thu, 22 May 2014 14:18:56 +0200 Subject: [PATCH 1/2] fixed the encoding parameter: it was passed as a Refine old-style argument, but it's a new one --- google/refine/refine.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/google/refine/refine.py b/google/refine/refine.py index 0c14a23..caf21bc 100644 --- a/google/refine/refine.py +++ b/google/refine/refine.py @@ -231,9 +231,19 @@ class Refine: if opt is None: return '' return str(opt) + + # the new APIs requires a json in the 'option' POST or GET argument + # POST is broken at the moment, so we send it in the URL + new_style_options = { + 'encoding': s(encoding), + } + params = { + 'options': json.dumps(new_style_options), + } + + # old style options options = { 'format': project_format, - 'encoding': s(encoding), 'separator': s(separator), 'ignore-lines': s(ignore_lines), 'header-lines': s(header_lines), @@ -258,7 +268,9 @@ class Refine: project_name = (project_file or 'New project').rsplit('.', 1)[0] project_name = os.path.basename(project_name) options['project-name'] = project_name - response = self.server.urlopen('create-project-from-upload', options) + response = self.server.urlopen( + 'create-project-from-upload', options, params + ) # expecting a redirect to the new project containing the id in the url url_params = urlparse.parse_qs( urlparse.urlparse(response.geturl()).query) From 2d94ac4e36cdba1e29fa0e05a844587f2b74f711 Mon Sep 17 00:00:00 2001 From: Stefano Parmesan Date: Tue, 12 Aug 2014 11:34:17 +0200 Subject: [PATCH 2/2] allow for extra parameters in new_project --- google/refine/refine.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/google/refine/refine.py b/google/refine/refine.py index caf21bc..c7c9b91 100644 --- a/google/refine/refine.py +++ b/google/refine/refine.py @@ -234,9 +234,9 @@ class Refine: # the new APIs requires a json in the 'option' POST or GET argument # POST is broken at the moment, so we send it in the URL - new_style_options = { + new_style_options = dict(opts, **{ 'encoding': s(encoding), - } + }) params = { 'options': json.dumps(new_style_options), }