Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Upload Field Condition #96

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

JVickery-TBS
Copy link

fix(dev): FieldStorage support;

  • Added condition to check for file attribute from FieldStorage object for ckanapi support.

CKANAPI uses cgi.FieldStorage (https://github.com/ckan/ckanapi/blob/master/ckanapi/localckan.py#L67) as to not require a lot of dependencies. Related issue on cgi.FieldStorage: https://bugs.python.org/issue19097

To support all py versions and cgi dependency versions, just checking for the file attribute might be good enough?

- Added condition to check for `file` attribute from FieldStorage object for `ckanapi` support.
@ThrawnCA
Copy link
Contributor

We've seen situations before where the FileStorage object exists but is blank, and it's necessary to further check that it has a truthy filename.

@JVickery-TBS
Copy link
Author

@ThrawnCA reckon I should add the filename attribute condition after the new file one? Or just replace the new file condition with filename?

@ThrawnCA
Copy link
Contributor

Offhand I'm not sure whether testing file and testing filename are interchangeable.

- Added condition to check for `filename` attribute from FieldStorage object for `ckanapi` support.
@JVickery-TBS
Copy link
Author

@ThrawnCA good enough for me! haha, I have added the filename condition in the case that the file attribute of a File like object is empty, but there is a filename. Should still get queued for validation and then the validation will fail and tell the user that their file is empty. This make sense to me

@@ -226,7 +226,8 @@ def before_update(self, context, current_resource, updated_resource):
if ((
# New file uploaded
(updated_resource.get(u'upload') or
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be an and. We want to check that the object exists and contains a non-blank file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants