Skip to content

Commit

Permalink
[#4801] Remove catch-all template controller
Browse files Browse the repository at this point in the history
Pylons used to have a catch-all route defined that tried to look for the
path in the provided URL in the templates folder. With changed in the
multiple static folders introduced in f9775a1 this route is never
reached, as we now set the catch-all route to look for the path in the
public folder(s) (which makes more sense to be honest).

Modified the middleware tests to reflect this.
  • Loading branch information
amercader committed Dec 19, 2019
1 parent e4d523e commit edeb59e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 90 deletions.
1 change: 0 additions & 1 deletion ckan/config/routing.py
Expand Up @@ -153,6 +153,5 @@ def make_map():
map.redirect('/favicon.ico', config.get('ckan.favicon'))

map.redirect('/*(url)/', '/{url}', _redirect_code='301 Moved Permanently')
map.connect('/*url', controller='template', action='view', ckan_core=True)

return map
45 changes: 0 additions & 45 deletions ckan/controllers/template.py

This file was deleted.

42 changes: 14 additions & 28 deletions ckan/tests/config/test_middleware.py
Expand Up @@ -137,24 +137,6 @@ def test_view():
return app


def test_ask_around_pylons_core_route_get(patched_app):
environ = {u"PATH_INFO": u"/tag", u"REQUEST_METHOD": u"GET"}
wsgiref.util.setup_testing_defaults(environ)

answers = patched_app.app.ask_around(environ)

assert answers == [(False, u"flask_app"), (True, u"pylons_app", u"core")]


def test_ask_around_pylons_core_route_post(patched_app):
environ = {u"PATH_INFO": u"/tag", u"REQUEST_METHOD": u"POST"}
wsgiref.util.setup_testing_defaults(environ)

answers = patched_app.app.ask_around(environ)

assert answers == [(False, u"flask_app"), (True, u"pylons_app", u"core")]


def test_flask_core_route_is_served_by_flask(patched_app):
res = patched_app.get(u"/")

Expand Down Expand Up @@ -184,8 +166,11 @@ def test_ask_around_pylons_extension_route_get_before_map(

answers = patched_app.app.ask_around(environ)

# Even though this route is defined in Pylons, there is catch all route
# in Flask for all requests to serve static files with the same name,
# so we get two positive answers
assert answers == [
(False, u"flask_app"),
(True, u"flask_app", u"core"),
(True, u"pylons_app", u"extension"),
]

Expand Down Expand Up @@ -214,11 +199,12 @@ def test_ask_around_pylons_extension_route_post_using_get(

answers = patched_app.app.ask_around(environ)

# We are going to get an answer from Pylons, but just because it will
# match the catch-all template route, hence the `core` origin.
# Even though this route is defined in Pylons, there is catch all route
# in Flask for all requests to serve static files with the same name,
# so we get two positive answers
assert answers == [
(False, u"flask_app"),
(True, u"pylons_app", u"core"),
(True, u"flask_app", u"core"),
(False, u"pylons_app"),
]

def test_ask_around_pylons_extension_route_get_after_map(
Expand All @@ -232,8 +218,11 @@ def test_ask_around_pylons_extension_route_get_after_map(

answers = patched_app.app.ask_around(environ)

# Even though this route is defined in Pylons, there is catch all route
# in Flask for all requests to serve static files with the same name,
# so we get two positive answers
assert answers == [
(False, u"flask_app"),
(True, u"flask_app", u"core"),
(True, u"pylons_app", u"extension"),
]

Expand Down Expand Up @@ -453,10 +442,7 @@ def test_ask_around_flask_core_route_post(app):

answers = ckan_app.ask_around(environ)

# Even though this route is defined in Flask, there is catch all route
# in Pylons for all requests to point arbitrary urls to templates with
# the same name, so we get two positive answers
assert answers == [
(True, u"flask_app", u"core"),
(True, u"pylons_app", u"core"),
(False, u"pylons_app"),
]
16 changes: 0 additions & 16 deletions ckan/tests/controllers/test_template.py

This file was deleted.

0 comments on commit edeb59e

Please sign in to comment.