Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fallback IDatasetForm plugins should force type, no fallback should force type='dataset' #2083

Merged
merged 4 commits into from
Dec 11, 2014
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions ckan/logic/action/create.py
Original file line number Diff line number Diff line change
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 = package_plugin.package_types()[0]
except (AttributeError, IndexError):
package_type = 'dataset'
# in case a 'dataset' plugin was registeres w/o fallback
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo - "registeres"

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