[ckan-changes] commit/ckanext-inspire: amercader: [harvester] Use data dict instead of model object to avoid problems with Sessions
Bitbucket
commits-noreply at bitbucket.org
Tue Nov 15 11:20:41 UTC 2011
1 new commit in ckanext-inspire:
https://bitbucket.org/okfn/ckanext-inspire/changeset/abf642ef2e75/
changeset: abf642ef2e75
user: amercader
date: 2011-11-15 12:20:23
summary: [harvester] Use data dict instead of model object to avoid problems with Sessions
affected #: 1 file
diff -r 3e7a6ade654279121d90e8e374e92b99a4586e30 -r abf642ef2e7577249b669ce7b0841fbc89c4f904 ckanext/inspire/harvesters.py
--- a/ckanext/inspire/harvesters.py
+++ b/ckanext/inspire/harvesters.py
@@ -356,17 +356,21 @@
if package == None:
# Create new package from data.
package = self._create_package_from_data(package_dict)
- log.info('Created new package ID %s with GEMINI guid %s', package.id, gemini_guid)
+ log.info('Created new package ID %s with GEMINI guid %s', package['id'], gemini_guid)
else:
package = self._create_package_from_data(package_dict, package = package)
- log.info('Updated existing package ID %s with existing GEMINI guid %s', package.id, gemini_guid)
+ log.info('Updated existing package ID %s with existing GEMINI guid %s', package['id'], gemini_guid)
# Set reference to package in the HarvestObject
- self.obj.package = package
- self.obj.save()
-
- assert gemini_guid == package.harvest_objects[0].guid
+ # (only for newly created objects, if we are reimporting the reference
+ # is alredy set)
+ if not self.obj.package_id or self.obj.package_id != package['id']:
+ self.obj.package_id = package['id']
+ self.obj.save()
+
+ assert gemini_guid == [e['value'] for e in package['extras'] if e['key'] == 'guid'][0]
+ assert self.obj.id == [e['value'] for e in package['extras'] if e['key'] == 'harvest_object_id'][0]
return package
def gen_new_name(self,title):
@@ -442,8 +446,7 @@
except ValidationError,e:
raise Exception('Validation Error: %s' % str(e.error_summary))
- # Return the actual package object
- return context['package']
+ return package_dict
def get_gemini_string_and_guid(self,content,url=None):
xml = etree.fromstring(content)
Repository URL: https://bitbucket.org/okfn/ckanext-inspire/
--
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