基于数据集程序包的ID,如何确定该程序包是由哪个收割机收割的,以及该收割机的基本URL是什么?
类似的东西:
guid = '65715c6e-bbaf-3def-982b-3b5156272da7'
harvest_source = getHarvestSource(guid)
if (harvest_source):
type = harvest_source.type() # whatever was set as the name attribute for this harvester class
base_url = harvest_source.url() # whatever was set as the URL in the admin interface
我还没有尝试过,但是通过阅读model,我期望像这样:
from ckan.model import Package
id = u'65715c6e-bbaf-3def-982b-3b5156272da7'
dataset = model.Package.get(id)
dataset_was_harvested = bool(dataset.harvest_objects > 0)
if dataset_was_harvested:
ho = dataset.harvest_objects[0] # there's not usually more than 1
source = ho.source # i.e. the harvest source is "the harvester"
source.url # i.e. the harvester's base url