Skip to content

Commit

Permalink
[#3196] Add Fanstatic middleware to Flask
Browse files Browse the repository at this point in the history
Hopefully just temporarily until we can replace it with something
better. This will be tested further on went the url_for stuff is
avaiable as well.

Changed wrong reference in a test
  • Loading branch information
amercader committed Aug 19, 2016
1 parent 0daf144 commit f7102f8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 22 additions & 0 deletions ckan/config/middleware/flask_app.py
Expand Up @@ -16,6 +16,7 @@

from beaker.middleware import SessionMiddleware
from paste.deploy.converters import asbool
from fanstatic import Fanstatic

from ckan.lib import helpers
from ckan.lib import jinja_extensions
Expand Down Expand Up @@ -135,6 +136,27 @@ def hello_world_post():
if hasattr(plugin, 'get_blueprint'):
app.register_extension_blueprint(plugin.get_blueprint())

# Start other middleware

# Fanstatic
if debug:
fanstatic_config = {
'versioning': True,
'recompute_hashes': True,
'minified': False,
'bottom': True,
'bundle': False,
}
else:
fanstatic_config = {
'versioning': True,
'recompute_hashes': False,
'minified': True,
'bottom': True,
'bundle': True,
}
app = Fanstatic(app, **fanstatic_config)

# Add a reference to the actual Flask app so it's easier to access
app._wsgi_app = flask_app

Expand Down
2 changes: 1 addition & 1 deletion ckan/tests/config/test_middleware.py
Expand Up @@ -96,7 +96,7 @@ def setup_class(cls):
# Add a custom route to the Flask app
app = cls._get_test_app()

flask_app = app.app.apps['flask_app']
flask_app = app.flask_app

def test_view():
return 'This was served from Flask'
Expand Down

0 comments on commit f7102f8

Please sign in to comment.