From ef173d91a4afcf4963fcb89688be40bff47e9c26 Mon Sep 17 00:00:00 2001 From: Jesse Vickery Date: Wed, 14 Feb 2024 18:02:08 +0000 Subject: [PATCH 1/3] fix(dev): FieldStorage support; - Added condition to check for `file` attribute from FieldStorage object for `ckanapi` support. --- ckanext/validation/plugin/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ckanext/validation/plugin/__init__.py b/ckanext/validation/plugin/__init__.py index d648709e..e38eb5b6 100644 --- a/ckanext/validation/plugin/__init__.py +++ b/ckanext/validation/plugin/__init__.py @@ -225,7 +225,8 @@ def before_update(self, context, current_resource, updated_resource): needs_validation = False if (( # New file uploaded - updated_resource.get(u'upload') or + (updated_resource.get(u'upload') or + getattr(updated_resource.get(u'upload'), 'file', False)) or # External URL changed updated_resource.get(u'url') != current_resource.get(u'url') or # Schema changed From 621021074e581f4901f008a3f32aa035f8de3ea2 Mon Sep 17 00:00:00 2001 From: Jesse Vickery Date: Fri, 16 Feb 2024 14:22:13 +0000 Subject: [PATCH 2/3] fix(dev): FieldStorage support; - Added condition to check for `filename` attribute from FieldStorage object for `ckanapi` support. --- ckanext/validation/plugin/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ckanext/validation/plugin/__init__.py b/ckanext/validation/plugin/__init__.py index e38eb5b6..2e2950cc 100644 --- a/ckanext/validation/plugin/__init__.py +++ b/ckanext/validation/plugin/__init__.py @@ -226,7 +226,8 @@ def before_update(self, context, current_resource, updated_resource): if (( # New file uploaded (updated_resource.get(u'upload') or - getattr(updated_resource.get(u'upload'), 'file', False)) or + getattr(updated_resource.get(u'upload'), 'file', False) or + getattr(updated_resource.get(u'upload'), 'filename', False)) or # External URL changed updated_resource.get(u'url') != current_resource.get(u'url') or # Schema changed From dfd3685a9cf90b5375fca4214c832263f8229d20 Mon Sep 17 00:00:00 2001 From: Jesse Vickery Date: Tue, 10 Dec 2024 15:02:24 +0000 Subject: [PATCH 3/3] fix(syntax): condition; - Check for `cgi.FieldStorage` instance. --- ckanext/validation/plugin/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ckanext/validation/plugin/__init__.py b/ckanext/validation/plugin/__init__.py index 2e2950cc..f9018174 100644 --- a/ckanext/validation/plugin/__init__.py +++ b/ckanext/validation/plugin/__init__.py @@ -226,8 +226,9 @@ def before_update(self, context, current_resource, updated_resource): if (( # New file uploaded (updated_resource.get(u'upload') or - getattr(updated_resource.get(u'upload'), 'file', False) or - getattr(updated_resource.get(u'upload'), 'filename', False)) or + (isinstance(updated_resource.get(u'upload'), cgi.FieldStorage) and # workaround falsy cgi.FieldStorage bug: https://bugs.python.org/issue19097 + (getattr(updated_resource.get(u'upload'), 'file', False) or + getattr(updated_resource.get(u'upload'), 'filename', False)))) or # External URL changed updated_resource.get(u'url') != current_resource.get(u'url') or # Schema changed