diff --git a/ckan/config/routing.py b/ckan/config/routing.py index 3e2549c7cef..8e990c82996 100644 --- a/ckan/config/routing.py +++ b/ckan/config/routing.py @@ -25,6 +25,8 @@ def make_map(): map.connect('/error/{action}', controller='error') map.connect('/error/{action}/{id}', controller='error') + map.connect('*url', controller='home', action='cors_options', conditions=dict(method=['OPTIONS'])) + # CUSTOM ROUTES HERE for plugin in routing_plugins: map = plugin.before_map(map) @@ -285,9 +287,6 @@ def make_map(): map.connect('ckanadmin_index', '/ckan-admin', controller='admin', action='index') map.connect('ckanadmin', '/ckan-admin/{action}', controller='admin') - map.connect('*url', controller='home', action='cors_options', - conditions=dict(method=['OPTIONS'])) - for plugin in routing_plugins: map = plugin.after_map(map) diff --git a/ckan/controllers/group.py b/ckan/controllers/group.py index 4b00ff6fab8..07e54777595 100644 --- a/ckan/controllers/group.py +++ b/ckan/controllers/group.py @@ -45,7 +45,14 @@ def register_pluggable_behaviour(map): # Create the routes based on group_type here, this will allow us to have top level # objects that are actually Groups, but first we need to make sure we are not # clobbering an existing domain + + # Our version of routes doesn't allow the environ to be passed into the match call + # and so we have to set it on the map instead. This looks like a threading problem + # waiting to happen but it is executed sequentially from instead the routing setup + e = map.environ + map.environ = {'REQUEST_METHOD': 'GET'} match = map.match('/%s/new' % (group_type,)) + map.environ = e if match: raise Exception, "Plugin %r would overwrite existing urls" % plugin diff --git a/ckan/controllers/package.py b/ckan/controllers/package.py index 8aaefd76ef9..d29b9777308 100644 --- a/ckan/controllers/package.py +++ b/ckan/controllers/package.py @@ -148,7 +148,7 @@ def check_data_dict(self, data_dict): # Resources might not exist yet (eg. Add Dataset) surplus_keys_schema = ['__extras', '__junk', 'state', 'groups', 'extras_validation', 'save', 'return_to', - 'resources'] + 'resources', 'type'] schema_keys = package_form_schema().keys() keys_in_schema = set(schema_keys) - set(surplus_keys_schema) @@ -158,7 +158,7 @@ def check_data_dict(self, data_dict): if missing_keys: #print data_dict #print missing_keys - log.info('incorrect form fields posted') + log.info('incorrect form fields posted, missing %s' % missing_keys ) raise DataError(data_dict) def setup_template_variables(self, context, data_dict): diff --git a/ckan/tests/functional/test_cors.py b/ckan/tests/functional/test_cors.py index 0481bac64c5..cdc315fa929 100644 --- a/ckan/tests/functional/test_cors.py +++ b/ckan/tests/functional/test_cors.py @@ -9,7 +9,8 @@ def test_options(self): self.ourapp = webtest.TestApp(self.wsgiapp) out = self.ourapp.request('/', method='OPTIONS') assert out.status_int == 200, out - print out + #print out + print out.body.decode('utf-8', 'ignore') assert len(str(out.body)) == 0, 'OPTIONS must return no content' def test_headers(self):