[ckan-dev] How to remove a field that is no longer valid
Brown, Mathew GCPE:EX
Mathew.Brown at gov.bc.ca
Tue Nov 17 19:22:20 UTC 2015
I’m going a bunch of edits to records using the ckanapi and one of them involves changing the ‘resource_status’ from ‘obsolete’ to ‘destroyed’. This means the ‘replacement_record’ field is no longer valid (though it was required when the status was obsolete). When I remove it using the highlighted line below, for some reason when I do a package_update, the field is still there.
Any idea how I remove a field from the record and then update the record?
Here’s my code
#use ckan api to modify record
demo = ckanapi.RemoteCKAN(domain,
api_key)
action='package_update'
for rec in full_record_result_list:
try:
obj = rec['object_name']
if obj in obs_list:
rec['resource_status'] = 'destroyed'
if 'replacement_record' in rec:
rec.pop('replacement_record',None)
demo.call_action(action,rec)
except:
pass
Thanks!
More information about the ckan-dev
mailing list