Skip to content

Commit

Permalink
Helper moved to test helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
brew committed May 26, 2016
1 parent fd3926e commit ac4ee76
Showing 1 changed file with 0 additions and 28 deletions.
28 changes: 0 additions & 28 deletions ckan/config/middleware.py
Expand Up @@ -757,31 +757,3 @@ def cleanup_pylons_response_string(environ):
environ['pylons.controller']._py_object.response._body = msg
except (KeyError, AttributeError):
pass


def find_flask_app(test_app):
'''
Helper function to recursively search the wsgi stack in `test_app` until
the flask_app is discovered.
Relies on each layer of the stack having a reference to the app they
wrap in either a .app attribute or .apps list.
'''
if isinstance(test_app, CKANFlask):
return test_app

try:
app = test_app.apps['flask_app'].app
except (AttributeError, KeyError):
pass
else:
return find_flask_app(app)

try:
app = test_app.app
except AttributeError:
print('No .app attribute. '
'Have all layers of the stack got '
'a reference to the app they wrap?')
else:
return find_flask_app(app)

0 comments on commit ac4ee76

Please sign in to comment.