From 5f24e96bfa13a604fdc56eb46dd3c86e0633162e Mon Sep 17 00:00:00 2001 From: Jari Voutilainen Date: Fri, 8 Mar 2024 14:14:12 +0200 Subject: [PATCH 1/4] Fix file uploads on localckan --- ckanapi/localckan.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ckanapi/localckan.py b/ckanapi/localckan.py index 1add7ab..7a54170 100644 --- a/ckanapi/localckan.py +++ b/ckanapi/localckan.py @@ -1,4 +1,4 @@ -from cgi import FieldStorage +from werkzeug.datastructures import FileStorage from tempfile import TemporaryFile from ckanapi.errors import CKANAPIError @@ -64,10 +64,10 @@ def call_action(self, action, data_dict=None, context=None, apikey=None, except (AttributeError, IOError): f = _write_temp_file(f) to_close.append(f) - field_storage = FieldStorage() - field_storage.file = f - field_storage.filename = filename - data_dict[fieldname] = field_storage + file_storage = FileStorage() + file_storage.stream = f + file_storage.filename = filename + data_dict[fieldname] = file_storage return self._get_action(action)(context, data_dict) finally: From 2f34fe45b669e9cb6ba8a68c00c3886f71364e56 Mon Sep 17 00:00:00 2001 From: Jari Voutilainen Date: Mon, 11 Mar 2024 09:34:15 +0200 Subject: [PATCH 2/4] Import from werkzeug locally so that the import is only used when initializing localCKAN --- ckanapi/localckan.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ckanapi/localckan.py b/ckanapi/localckan.py index 7a54170..1211329 100644 --- a/ckanapi/localckan.py +++ b/ckanapi/localckan.py @@ -1,4 +1,3 @@ -from werkzeug.datastructures import FileStorage from tempfile import TemporaryFile from ckanapi.errors import CKANAPIError @@ -64,6 +63,9 @@ def call_action(self, action, data_dict=None, context=None, apikey=None, except (AttributeError, IOError): f = _write_temp_file(f) to_close.append(f) + + from werkzeug.datastructures import FileStorage + file_storage = FileStorage() file_storage.stream = f file_storage.filename = filename From 5f2d136421fc4e10c6d04cb1e7c3357b8c6f0c5f Mon Sep 17 00:00:00 2001 From: Jari Voutilainen Date: Mon, 11 Mar 2024 09:35:34 +0200 Subject: [PATCH 3/4] Run tests on current python versions --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8c3b210..6124b6d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,7 +4,7 @@ jobs: test: strategy: matrix: - python-version: ["2.7", "3.8"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] runs-on: ubuntu-latest container: # INFO: python 2 is no longer supported in From 83468a3938b1ba98545a60e87c93ed1a6cbb2ffe Mon Sep 17 00:00:00 2001 From: Jari Voutilainen Date: Mon, 11 Mar 2024 09:39:08 +0200 Subject: [PATCH 4/4] Update pyfakefs to support python 3.12 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index fa1fa06..77e8356 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ 'simplejson', ] tests_require=[ - 'pyfakefs==3.6.1', + 'pyfakefs==5.3.5', ]