Closed metaodi closed 6 years ago
This PR also fixes the controller tests, which now require a test_request_context (see https://github.com/ckan/ckan/pull/3228). This is unrelated, but the build fails otherwise.
@amercader When writing tests I noticed something strange: if the URI of a resource is empty, it is saved with the string "None"
is CKAN. I guess it's because it gets explicitly assigned the value None
. I guess later on this is being serialized using str()
or something similar, which then creates the string "None"
.
In this PR, I now changed the value from None
to an empty string. I think this is actually a very good solution, as you end up with an empty string in CKAN and all the conditionals (if value
etc.) still work as the empty string is falsy in Python. WDYT?
The other solution would be to change to serialization, and make sure None
values are saved as null
or an empty string.
It probably would make sense to implement this consequently, as we have now empty strings and None
values.
See https://github.com/ckan/ckan/issues/3780 for backwards-compatible test_request_context
ping @amercader
So I just removed my changed for the test_request_context
since https://github.com/ckan/ckan/pull/3782 has been merged.
@amercader do you have time to review this PR?
sorry @metaodi I've been a bit swamped recently. This looks great. What's the reason behind 31042e69?
@amercader see my comment above, let me know if you need more information.
@amercader okay I updated the other URIs as well, and to be consistent I updated _object_value
to return an empty string if the value is not found, e.g. _contact_details()
should return an empty string for all attributes not only uri
, do you agree?
Sounds good @metaodi, many thanks for this!
Just checking - does this apply to the DCAT JSON Harvester or will that need to implemented still?
@camfindlay the DCAT JSON harvester hasn't been updated in a long time. Current efforts are focused on the RDF based functionality.
thanks @amercader - we're making use of DCAT JSON so take it if we'd like this same improvement we'll need to raise a PR and add a similar check to avoid harvesting when resources haven't changed. ^ CC/ @dythya
Fixes #91