[ckan-changes] commit/ckanext-harvest: 2 new changesets

Bitbucket commits-noreply at bitbucket.org
Thu Sep 8 09:29:34 UTC 2011


2 new changesets in ckanext-harvest:

http://bitbucket.org/okfn/ckanext-harvest/changeset/fb88531fa6ca/
changeset:   fb88531fa6ca
user:        amercader
date:        2011-09-08 10:58:21
summary:     Separate gather and object errors in reports. Add info about guid and object id in the object ones
affected #:  2 files (1.0 KB)

--- a/ckanext/harvest/lib/__init__.py	Tue Sep 06 18:25:17 2011 +0100
+++ b/ckanext/harvest/lib/__init__.py	Thu Sep 08 09:58:21 2011 +0100
@@ -28,7 +28,7 @@
     out = {'next_harvest':'',
            'last_harvest_request':'',
            'last_harvest_statistics':{'added':0,'updated':0,'errors':0},
-           'last_harvest_errors':[],
+           'last_harvest_errors':{'gather':[],'object':[]},
            'overall_statistics':{'added':0, 'errors':0},
            'packages':[]}
     # Get next scheduled job
@@ -79,11 +79,11 @@
                                             + object_errors.count()
         if detailed: 
             for gather_error in last_job.gather_errors:
-                out['last_harvest_errors'].append(gather_error.message)
+                out['last_harvest_errors']['gather'].append(gather_error.message)
 
             for object_error in object_errors:
-                msg = 'GUID %s: %s' % (object_error.object.guid, object_error.message)
-                out['last_harvest_errors'].append(msg)
+                err = {'object_id':object_error.object.id,'object_guid':object_error.object.guid,'message': object_error.message}
+                out['last_harvest_errors']['object'].append(err)
 
         # Overall statistics
         packages = Session.query(distinct(HarvestObject.package_id),Package.name) \


--- a/ckanext/harvest/templates/source/read.html	Tue Sep 06 18:25:17 2011 +0100
+++ b/ckanext/harvest/templates/source/read.html	Thu Sep 08 09:58:21 2011 +0100
@@ -55,12 +55,33 @@
             <td>
                 Last Harvest Errors: ${c.source.status.last_harvest_statistics.errors}<br/><py:choose>
-                    <py:when test="len(c.source.status.last_harvest_errors)>0">
+                    <py:when test="len(c.source.status.last_harvest_errors.gather)>0">
+                        <i>Gathering errors</i><ul>
-                        <li py:for="error in c.source.status.last_harvest_errors">${error}</li>
+                        <li py:for="error in c.source.status.last_harvest_errors.gather">
+                            <?python
+                                lines = error.split('\n')
+                            ?>
+                            <div py:for="line in lines">${line}</div>
+                        </li></ul></py:when></py:choose>
+                <py:choose>
+                    <py:when test="len(c.source.status.last_harvest_errors.object)>0">
+                       <i>Object errors</i>
+                        <ul>
+                        <li py:for="error in c.source.status.last_harvest_errors.object">
+                            <div>GUID ${error.object_guid}</div>
+                            <?python
+                                lines = error['message'].split('\n')
+                            ?>
+                            <div py:for="line in lines">${line}</div>
+                        </li>
+                        </ul>
+                    </py:when>
+                </py:choose>
+
                 Last Harvest Added: ${c.source.status.last_harvest_statistics.added}<br/>
                 Last Harvest Updated: ${c.source.status.last_harvest_statistics.updated}<br/>
                 Last Harvest: ${c.source.status.last_harvest_request} <br/>


http://bitbucket.org/okfn/ckanext-harvest/changeset/eecf91de356e/
changeset:   eecf91de356e
user:        amercader
date:        2011-09-08 11:27:36
summary:     Add link to source documents from object errors
affected #:  3 files (1.1 KB)

--- a/ckanext/harvest/controllers/view.py	Thu Sep 08 09:58:21 2011 +0100
+++ b/ckanext/harvest/controllers/view.py	Thu Sep 08 10:27:36 2011 +0100
@@ -1,3 +1,5 @@
+from lxml import etree
+from lxml.etree import XMLSyntaxError
 from pylons.i18n import _
 
 import ckan.lib.helpers as h, json
@@ -9,7 +11,8 @@
 from ckanext.harvest.logic.schema import harvest_source_form_schema
 from ckanext.harvest.lib import create_harvest_source, edit_harvest_source, \
                                 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
 import logging
 log = logging.getLogger(__name__)
@@ -147,3 +150,28 @@
             h.flash_error(msg)
 
         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'))
+


--- a/ckanext/harvest/plugin.py	Thu Sep 08 09:58:21 2011 +0100
+++ b/ckanext/harvest/plugin.py	Thu Sep 08 10:27:36 2011 +0100
@@ -34,6 +34,9 @@
 
         map.connect('harvesting_job_create', '/harvest/refresh/:id',controller=controller, 
                 action='create_harvesting_job')
+
+        map.connect('/harvest/object/:id', controller=controller, action='show_object')
+
         return map
 
     def update_config(self, config):


--- a/ckanext/harvest/templates/source/read.html	Thu Sep 08 09:58:21 2011 +0100
+++ b/ckanext/harvest/templates/source/read.html	Thu Sep 08 10:27:36 2011 +0100
@@ -72,7 +72,7 @@
                        <i>Object errors</i><ul><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
                                 lines = error['message'].split('\n')
                             ?>

Repository URL: https://bitbucket.org/okfn/ckanext-harvest/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.




More information about the ckan-changes mailing list