[#8] Provide a config option to continue after validation errors

This can be set instance wide on the ini file with

ckanext.spatial.harvest.continue_on_validation_errors

or per source, adding continue_on_validation_errors=true to the source
config.
This commit is contained in:
amercader 2013-02-15 14:47:25 +00:00
parent 596bdbf5d0
commit 4964ce9ec3
2 changed files with 11 additions and 2 deletions

View File

@ -199,6 +199,10 @@ This is the recommended setting, but if necessary, it can be overridden with the
ckanext.spatial.harvest.user_name = harvest
By default, the import stage will stop if the validation of the harvested document fails. This can be
modified setting the ``ckanext.spatial.harvest.continue_on_validation_errors`` to True. The setting can
also be applied at the source level setting to True the ``continue_on_validation_errors`` key on the source
configuration object.
Harvest Metadata API

View File

@ -18,6 +18,7 @@ from owslib import wms
import requests
from lxml import etree
from ckan import plugins as p
from ckan import model
from ckan.lib.helpers import json
from ckan import logic
@ -527,8 +528,12 @@ class SpatialHarvester(HarvesterBase):
# Validate ISO document
is_valid, profile, errors = self._validate_document(harvest_object.content, harvest_object)
if not is_valid:
# TODO: Provide an option to continue anyway
return False
# If validation errors were found, import will stop unless
# configuration per source or per instance says otherwise
continue_import = p.toolkit.asbool(config.get('ckanext.spatial.harvest.continue_on_validation_errors', False)) or \
self.source_config.get('continue_on_validation_errors')
if not continue_import:
return False
# Parse ISO document