Skip to content

Commit

Permalink
[#2083] package_create: make sure datasets have a valid type
Browse files Browse the repository at this point in the history
  • Loading branch information
wardi committed Nov 24, 2014
1 parent c1f154e commit 526bd76
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions ckan/logic/action/create.py
Expand Up @@ -127,8 +127,19 @@ def package_create(context, data_dict):
model = context['model']
user = context['user']

package_type = data_dict.get('type')
package_plugin = lib_plugins.lookup_package_plugin(package_type)
if 'type' not in data_dict:
package_plugin = lib_plugins.lookup_package_plugin()
try:
# use first type as default if user didn't provide type
package_type = plugin.package_types()[0]
except AttributeError:
package_type = 'dataset'
# in case a 'dataset' plugin was registeres w/o fallback
package_plugin = lib_plugins.lookup_package_plugin(package_type)
data_dict['type'] = package_type
else:
package_plugin = lib_plugins.lookup_package_plugin(data_dict['type'])

if 'schema' in context:
schema = context['schema']
else:
Expand Down

0 comments on commit 526bd76

Please sign in to comment.