Due to #3011 I recently set
ckan.views.default_views =
in my INI, so that by default no views are created at all.
Since then I'm getting many warnings of the form
2016-06-06 16:23:03,537 WARNI [ckan.lib.datapreview] Plugin for view could not be found
The problem seems to be that ckan.lib.datapreview.get_default_view_plugins splits the configuration value in a rather naive way:
default_view_types = config.get('ckan.views.default_views').split(' ')
Using .split(' ') will split on a single space, thereby creating problems with leading, trailing, and multiple spaces:
>>> ' foo bar '.split(' ')
['', 'foo', '', 'bar', '', '']
Even worse:
To simply split on whitespace (as was probably intended), use the no-argument form of split:
>>> ' foo bar '.split()
['foo', 'bar']
>>> ''.split()
[]
Using split() instead of split(' ') fixes the issue for me. I'll create a PR.
A quick grep turns up a few other places with similar code (although I didn't check whether they are also problematic):
$ grep -r "split(' ')" --include "*.py" ckan ckanext/
ckan/logic/action/get.py: fq = ' '.join(p for p in fq.split(' ')
ckan/lib/helpers.py: kwargs.get('action', '')).split(' ')
ckan/lib/datapreview.py: default_view_types = config.get('ckan.views.default_views').split(' ')
ckan/ckan_nose_plugin.py:## # testname = testname.split(' ')[1]
$ grep -r 'split(" ")' --include "*.py" ckan ckanext/
ckan/lib/base.py: in config['ckan.cors.origin_whitelist'].split(" "):
Due to #3011 I recently set
in my INI, so that by default no views are created at all.
Since then I'm getting many warnings of the form
The problem seems to be that
ckan.lib.datapreview.get_default_view_pluginssplits the configuration value in a rather naive way:Using
.split(' ')will split on a single space, thereby creating problems with leading, trailing, and multiple spaces:Even worse:
To simply split on whitespace (as was probably intended), use the no-argument form of
split:Using
split()instead ofsplit(' ')fixes the issue for me. I'll create a PR.A quick grep turns up a few other places with similar code (although I didn't check whether they are also problematic):