Skip to content

Commit

Permalink
Allow not returning the package dict when creating or updating
Browse files Browse the repository at this point in the history
This avoids calling package_show
  • Loading branch information
amercader authored and tobes committed Aug 15, 2012
1 parent 302042a commit 6e43373
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions ckan/logic/action/create.py
Expand Up @@ -98,7 +98,8 @@ def package_create(context, data_dict):
which groups exist call ``group_list()``
:type groups: list of dictionaries
:returns: the newly created dataset
:returns: the newly created dataset (if 'return_package_dict' is True in the
context, which is the default. Otherwise returns None)
:rtype: dictionary
'''
Expand Down Expand Up @@ -162,7 +163,10 @@ def package_create(context, data_dict):
## this is added so that the rest controller can make a new location
context["id"] = pkg.id
log.debug('Created object %s' % str(pkg.name))
return _get_action('package_show')(context, {'id':context['id']})

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

return _get_action('package_show')(context, {'id':context['id']}) if return_package_dict else None

def package_create_validate(context, data_dict):
model = context['model']
Expand Down
8 changes: 6 additions & 2 deletions ckan/logic/action/update.py
Expand Up @@ -213,7 +213,8 @@ def package_update(context, data_dict):
:param id: the name or id of the dataset to update
:type id: string
:returns: the updated dataset
:returns: the updated dataset (if 'return_package_dict' is True in the
context, which is the default. Otherwise returns None)
:rtype: dictionary
'''
Expand Down Expand Up @@ -273,7 +274,10 @@ def package_update(context, data_dict):
model.repo.commit()

log.debug('Updated object %s' % str(pkg.name))
return _get_action('package_show')(context, data_dict)

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

return _get_action('package_show')(context, data_dict) if return_package_dict else None

def package_update_validate(context, data_dict):
model = context['model']
Expand Down

0 comments on commit 6e43373

Please sign in to comment.