Skip to content

Commit

Permalink
[#2788] Use return_id_only instead of return_package_dict
Browse files Browse the repository at this point in the history
Suggested by @tobes, as it is more backwards compatible
  • Loading branch information
amercader committed Aug 14, 2012
1 parent c8997b6 commit 583c073
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
11 changes: 5 additions & 6 deletions ckan/logic/action/create.py
Expand Up @@ -98,9 +98,8 @@ def package_create(context, data_dict):
which groups exist call ``group_list()``
:type groups: list of dictionaries
:returns: the newly created dataset (if 'return_package_dict' is True in the
context, which is the default. Otherwise returns just the dataset
id)
:returns: the newly created dataset (unless 'return_id_only' is set to True
in the context, in which case just the dataset id will be returned)
:rtype: dictionary
'''
Expand Down Expand Up @@ -165,10 +164,10 @@ def package_create(context, data_dict):
context["id"] = pkg.id
log.debug('Created object %s' % str(pkg.name))

return_package_dict = context.get('return_package_dict',True)
return_id_only = context.get('return_id_only', False)

output = _get_action('package_show')(context, {'id':context['id']}) \
if return_package_dict else context['id']
output = context['id'] if return_id_only \
else _get_action('package_show')(context, {'id':context['id']})

return output

Expand Down
6 changes: 3 additions & 3 deletions ckan/logic/action/update.py
Expand Up @@ -276,10 +276,10 @@ def package_update(context, data_dict):

log.debug('Updated object %s' % str(pkg.name))

return_package_dict = context.get('return_package_dict',True)
return_id_only = context.get('return_id_only', False)

output = _get_action('package_show')(context, {'id': data_dict['id']}) \
if return_package_dict else data_dict['id']
output = data_dict['id'] if return_id_only \
else _get_action('package_show')(context, {'id': data_dict['id']})

return output

Expand Down

0 comments on commit 583c073

Please sign in to comment.