Merge branch 'add-harvesting-of-organizations' of git://github.com/metaodi/ckanext-harvest into metaodi-add-harvesting-of-organizations

This commit is contained in:
amercader 2013-10-15 17:49:28 +01:00
commit 49999893e7
1 changed files with 18 additions and 17 deletions

View File

@ -309,22 +309,23 @@ class CKANHarvester(HarvesterBase):
remote_org = package_dict['owner_org'] remote_org = package_dict['owner_org']
context = {'model': model, 'session': Session, 'user': 'harvest'} context = {'model': model, 'session': Session, 'user': 'harvest'}
try: if remote_org:
data_dict = {'id': remote_org} try:
org = get_action('organization_show')(context, data_dict) data_dict = {'id': remote_org}
validated_org = org['id'] org = get_action('organization_show')(context, data_dict)
except NotFound, e: validated_org = org['id']
log.info('Organization %s is not available' % remote_org) except NotFound, e:
if remote_orgs == 'create': log.info('Organization %s is not available' % remote_org)
try: if remote_orgs == 'create':
org = self._get_group(harvest_object.source.url, remote_org) try:
for key in ['packages', 'created', 'users', 'groups', 'tags', 'extras', 'display_name', 'type']: org = self._get_group(harvest_object.source.url, remote_org)
org.pop(key, None) for key in ['packages', 'created', 'users', 'groups', 'tags', 'extras', 'display_name', 'type']:
get_action('organization_create')(context, org) org.pop(key, None)
log.info('Organization %s has been newly created' % remote_org) get_action('organization_create')(context, org)
validated_org = org['id'] log.info('Organization %s has been newly created' % remote_org)
except: validated_org = org['id']
log.error('Could not get remote org %s' % remote_org) except:
log.error('Could not get remote org %s' % remote_org)
package_dict['owner_org'] = validated_org package_dict['owner_org'] = validated_org