Add link to source documents from object errors
This commit is contained in:
parent
31c1ea1c21
commit
63afd199a9
|
@ -1,3 +1,5 @@
|
||||||
|
from lxml import etree
|
||||||
|
from lxml.etree import XMLSyntaxError
|
||||||
from pylons.i18n import _
|
from pylons.i18n import _
|
||||||
|
|
||||||
import ckan.lib.helpers as h, json
|
import ckan.lib.helpers as h, json
|
||||||
|
@ -9,7 +11,8 @@ from ckan.logic import NotFound, ValidationError
|
||||||
from ckanext.harvest.logic.schema import harvest_source_form_schema
|
from ckanext.harvest.logic.schema import harvest_source_form_schema
|
||||||
from ckanext.harvest.lib import create_harvest_source, edit_harvest_source, \
|
from ckanext.harvest.lib import create_harvest_source, edit_harvest_source, \
|
||||||
get_harvest_source, get_harvest_sources, \
|
get_harvest_source, get_harvest_sources, \
|
||||||
create_harvest_job, get_registered_harvesters_info
|
create_harvest_job, get_registered_harvesters_info, \
|
||||||
|
get_harvest_object
|
||||||
from ckan.lib.helpers import Page
|
from ckan.lib.helpers import Page
|
||||||
import logging
|
import logging
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
@ -147,3 +150,28 @@ class ViewController(BaseController):
|
||||||
h.flash_error(msg)
|
h.flash_error(msg)
|
||||||
|
|
||||||
redirect(h.url_for('harvest'))
|
redirect(h.url_for('harvest'))
|
||||||
|
|
||||||
|
def show_object(self,id):
|
||||||
|
try:
|
||||||
|
object = get_harvest_object(id)
|
||||||
|
# Check content type. It will probably be either XML or JSON
|
||||||
|
try:
|
||||||
|
etree.fromstring(object['content'])
|
||||||
|
response.content_type = 'application/xml'
|
||||||
|
except XMLSyntaxError:
|
||||||
|
try:
|
||||||
|
json.loads(object['content'])
|
||||||
|
response.content_type = 'application/json'
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
response.headers["Content-Length"] = len(object['content'])
|
||||||
|
return object['content']
|
||||||
|
except NotFound:
|
||||||
|
abort(404,_('Harvest object not found'))
|
||||||
|
except Exception, e:
|
||||||
|
msg = 'An error occurred: [%s]' % e.message
|
||||||
|
h.flash_error(msg)
|
||||||
|
|
||||||
|
redirect(h.url_for('harvest'))
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,9 @@ class Harvest(SingletonPlugin):
|
||||||
|
|
||||||
map.connect('harvesting_job_create', '/harvest/refresh/:id',controller=controller,
|
map.connect('harvesting_job_create', '/harvest/refresh/:id',controller=controller,
|
||||||
action='create_harvesting_job')
|
action='create_harvesting_job')
|
||||||
|
|
||||||
|
map.connect('/harvest/object/:id', controller=controller, action='show_object')
|
||||||
|
|
||||||
return map
|
return map
|
||||||
|
|
||||||
def update_config(self, config):
|
def update_config(self, config):
|
||||||
|
|
|
@ -72,7 +72,7 @@
|
||||||
<i>Object errors</i>
|
<i>Object errors</i>
|
||||||
<ul>
|
<ul>
|
||||||
<li py:for="error in c.source.status.last_harvest_errors.object">
|
<li py:for="error in c.source.status.last_harvest_errors.object">
|
||||||
<div>GUID ${error.object_guid}</div>
|
<div>GUID <a href="${g.site_url}/harvest/object/${error.object_id}">${error.object_guid}</a></div>
|
||||||
<?python
|
<?python
|
||||||
lines = error['message'].split('\n')
|
lines = error['message'].split('\n')
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in New Issue