From 526bd76bc7688825a3e4b79a4647d7edc95734f2 Mon Sep 17 00:00:00 2001 From: Ian Ward Date: Mon, 24 Nov 2014 14:17:33 -0500 Subject: [PATCH] [#2083] package_create: make sure datasets have a valid type --- ckan/logic/action/create.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/ckan/logic/action/create.py b/ckan/logic/action/create.py index fef14af6489..814ff288ca6 100644 --- a/ckan/logic/action/create.py +++ b/ckan/logic/action/create.py @@ -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: