[ckan-changes] commit/ckanext-harvest: amercader: Use get_action function instead of directly calling the action functions
Bitbucket
commits-noreply at bitbucket.org
Wed Oct 26 16:26:32 UTC 2011
1 new commit in ckanext-harvest:
https://bitbucket.org/okfn/ckanext-harvest/changeset/1fc2cfa9aa3e/
changeset: 1fc2cfa9aa3e
user: amercader
date: 2011-10-26 18:26:18
summary: Use get_action function instead of directly calling the action functions
affected #: 1 file
diff -r 189d8406097f1a1fcc9467644aba0e1b35add586 -r 1fc2cfa9aa3ef4448f80dda4e956f50d6e5a5df0 ckanext/harvest/harvesters/base.py
--- a/ckanext/harvest/harvesters/base.py
+++ b/ckanext/harvest/harvesters/base.py
@@ -3,10 +3,8 @@
from ckan import model
from ckan.model import Session, Package
-from ckan.logic import ValidationError, NotFound
-from ckan.logic.action.create import package_create_rest
-from ckan.logic.action.update import package_update_rest
-from ckan.logic.action.get import package_show
+from ckan.logic import ValidationError, NotFound, get_action
+
from ckan.logic.schema import default_package_schema
from ckan.lib.navl.validators import ignore_missing
from ckan.lib.munge import munge_title_to_name, munge_tag
@@ -125,14 +123,14 @@
data_dict = {}
data_dict['id'] = package_dict['id']
try:
- existing_package_dict = package_show(context, data_dict)
+ existing_package_dict = get_action('package_show')(context, data_dict)
# Check modified date
if not 'metadata_modified' in package_dict or \
package_dict['metadata_modified'] > existing_package_dict.get('metadata_modified'):
log.info('Package with GUID %s exists and needs to be updated' % harvest_object.guid)
# Update package
context.update({'id':package_dict['id']})
- updated_package = package_update_rest(context, package_dict)
+ updated_package = get_action('package_update_rest')(context, package_dict)
harvest_object.package_id = updated_package['id']
harvest_object.save()
@@ -146,7 +144,7 @@
package_dict['name'] = self._check_name(package_dict['name'])
log.info('Package with GUID %s does not exist, let\'s create it' % harvest_object.guid)
- new_package = package_create_rest(context, package_dict)
+ new_package = get_action('package_create_rest')(context, package_dict)
harvest_object.package_id = new_package['id']
harvest_object.save()
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