From 4d20d50fad293653d08d5b8b9f20a44575b3ae5e Mon Sep 17 00:00:00 2001 From: Ross Jones Date: Tue, 3 Jan 2012 13:42:18 +0000 Subject: [PATCH] Updated the routing for packages and trying (failed) to check whether the new route already exists or not --- ckan/controllers/group.py | 10 +++++++--- ckan/controllers/package.py | 8 +++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/ckan/controllers/group.py b/ckan/controllers/group.py index 56400c01af1..4b434bcc379 100644 --- a/ckan/controllers/group.py +++ b/ckan/controllers/group.py @@ -42,9 +42,13 @@ def register_pluggable_behaviour(map): _default_controller_behaviour = plugin for group_type in plugin.group_types(): - # Create the routes based on group_type here..... - map.connect('/%s/new' % (group_type,), controller='group', action='new') - map.connect('%s_read' % (group_type,), '/%s/{id}' % (group_type,), controller='group', action='read') + # 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 + map.connect('%s_new' % (group_type,), + '/%s/new' % (group_type,), controller='group', action='new') + map.connect('%s_read' % (group_type,), + '/%s/{id}' % (group_type,), controller='group', action='read') map.connect('%s_action' % (group_type,), '/%s/{action}/{id}' % (group_type,), controller='group', requirements=dict(action='|'.join(['edit', 'authz', 'history' ])) diff --git a/ckan/controllers/package.py b/ckan/controllers/package.py index a71df1eb4ab..8aaefd76ef9 100644 --- a/ckan/controllers/package.py +++ b/ckan/controllers/package.py @@ -66,7 +66,7 @@ def register_pluggable_behaviour(map): exception will be raised. """ global _default_controller_behaviour - + # Check this method hasn't been invoked already. # TODO: This method seems to be being invoked more than once during running of # the tests. So I've disbabled this check until I figure out why. @@ -84,7 +84,13 @@ def register_pluggable_behaviour(map): for package_type in plugin.package_types(): # Create a connection between the newly named type and the package controller + # but first we need to make sure we are not clobbering an existing domain map.connect('/%s/new' % (package_type,), controller='package', action='new') + map.connect('%s_read' % (package_type,), '/%s/{id}' % (package_type,), controller='package', action='read') + map.connect('%s_action' % (package_type,), + '/%s/{action}/{id}' % (package_type,), controller='package', + requirements=dict(action='|'.join(['edit', 'authz', 'history' ])) + ) if package_type in _controller_behaviour_for: raise ValueError, "An existing IDatasetForm is "\