Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Deal with blueprints without static folders.

  • Loading branch information...
commit 747aa9c0d1b036bd3cc65b5cd278e48a97ac8af2 1 parent 82ce4dc
@miracle2k authored
Showing with 15 additions and 3 deletions.
  1. +10 −3 src/flask_assets.py
  2. +5 −0 tests/test_integration.py
View
13 src/flask_assets.py
@@ -113,9 +113,16 @@ def get_static_folder(app_or_blueprint):
In newer Flask versions this can be customized, in older
ones (<=0.6) the folder is fixed.
"""
- if hasattr(app_or_blueprint, 'static_folder'):
- return app_or_blueprint.static_folder
- return path.join(app_or_blueprint.root_path, 'static')
+ if not hasattr(app_or_blueprint, 'static_folder'):
+ # I believe this is for app objects in very old Flask
+ # versions that did not support ccustom static folders.
+ return path.join(app_or_blueprint.root_path, 'static')
+
+ if not app_or_blueprint.has_static_folder:
+ # Use an exception type here that is not hidden by spit_prefix.
+ raise TypeError(('The referenced blueprint %s has no static '
+ 'folder.') % app_or_blueprint)
+ return app_or_blueprint.static_folder
class FlaskResolver(Resolver):
View
5 tests/test_integration.py
@@ -229,6 +229,11 @@ def test_blueprint_urls(self):
self.env.expire = False
assert self.mkbundle(output='module/out', debug=False).urls() == ['/rasputin/out']
+ def test_blueprint_no_static_folder(self):
+ """Test dealing with a blueprint without a static folder."""
+ self.make_blueprint('module')
+ assert_raises(TypeError, self.mkbundle('module/foo').urls)
+
def test_cssrewrite(self):
"""Make sure cssrewrite works with Blueprints.
"""
Please sign in to comment.
Something went wrong with that request. Please try again.