Skip to content

Commit

Permalink
Fixed the routing to make sure we don't have the catch all cors_handl…
Browse files Browse the repository at this point in the history
…er before we want to check for the existence (or not) of the group urls.
  • Loading branch information
rossjones committed Jan 3, 2012
1 parent 7007f26 commit 4ab76d0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
8 changes: 5 additions & 3 deletions ckan/config/routing.py
Expand Up @@ -28,9 +28,7 @@ def make_map():
# CUSTOM ROUTES HERE
for plugin in routing_plugins:
map = plugin.before_map(map)

map.connect('*url', controller='home', action='cors_options',
conditions=dict(method=['OPTIONS']))

map.connect('home', '/', controller='home', action='index')
map.connect('/locale', controller='home', action='locale')
map.connect('about', '/about', controller='home', action='about')
Expand Down Expand Up @@ -287,9 +285,13 @@ 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)


map.redirect('/*(url)/', '/{url}',
_redirect_code='301 Moved Permanently')
map.connect('/*url', controller='template', action='view')
Expand Down
8 changes: 3 additions & 5 deletions ckan/controllers/group.py
Expand Up @@ -45,11 +45,9 @@ 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
from routes import url_for

u = url_for('/%s/new' % (group_type,) )
if u != '%s_new' % (group_type,):
raise Exception, "Plugin %r would overwrite the default group urls" % plugin
match = map.match('/%s/new' % (group_type,))
if match:
raise Exception, "Plugin %r would overwrite existing urls" % plugin

map.connect('%s_new' % (group_type,),
'/%s/new' % (group_type,), controller='group', action='new')
Expand Down
4 changes: 0 additions & 4 deletions ckan/controllers/package.py
Expand Up @@ -85,10 +85,6 @@ 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
if package_type == 'package':
raise Exception, "The plugin %r would overwrite the default package " \
"implementation urls" % plugin

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,),
Expand Down

0 comments on commit 4ab76d0

Please sign in to comment.