[ckan-changes] commit/ckanext-harvest: amercader: Modify import command to avoid problems with the Session

Bitbucket commits-noreply at bitbucket.org
Tue Nov 15 11:26:33 UTC 2011


1 new commit in ckanext-harvest:


https://bitbucket.org/okfn/ckanext-harvest/changeset/3b95a87964c0/
changeset:   3b95a87964c0
user:        amercader
date:        2011-11-15 12:26:24
summary:     Modify import command to avoid problems with the Session
affected #:  1 file

diff -r 1fc2cfa9aa3ef4448f80dda4e956f50d6e5a5df0 -r 3b95a87964c0721f1b3f8bab1feaaaa658e7b58f ckanext/harvest/lib/__init__.py
--- a/ckanext/harvest/lib/__init__.py
+++ b/ckanext/harvest/lib/__init__.py
@@ -346,7 +346,7 @@
         if not source:
             raise NotFound('Harvest source %s does not exist' % source_id)
 
-        last_objects = Session.query(HarvestObject) \
+        last_objects_ids = Session.query(HarvestObject.id) \
                 .join(HarvestJob) \
                 .filter(HarvestJob.source==source) \
                 .filter(HarvestObject.package!=None) \
@@ -355,7 +355,7 @@
                 .order_by(HarvestObject.gathered.desc()) \
                 .all()
     else:
-        last_objects = Session.query(HarvestObject) \
+        last_objects_ids = Session.query(HarvestObject.id) \
                 .filter(HarvestObject.package!=None) \
                 .order_by(HarvestObject.guid) \
                 .order_by(HarvestObject.metadata_modified_date.desc()) \
@@ -365,7 +365,8 @@
 
     last_obj_guid = ''
     imported_objects = []
-    for obj in last_objects:
+    for obj_id in last_objects_ids:
+        obj = Session.query(HarvestObject).get(obj_id)
         if obj.guid != last_obj_guid:
             imported_objects.append(obj)
             for harvester in PluginImplementations(IHarvester):
@@ -373,8 +374,8 @@
                     if hasattr(harvester,'force_import'):
                         harvester.force_import = True
                     harvester.import_stage(obj)
+                    break
         last_obj_guid = obj.guid
-    
 
     return imported_objects

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