Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix load_path breaking output url generation.

Closes #35.
  • Loading branch information...
commit f86f45b0d30568be6192541bb6a3398919c70404 1 parent 2807c2c
@miracle2k authored
Showing with 22 additions and 8 deletions.
  1. +16 −8 src/flask_assets.py
  2. +6 −0 tests/test_integration.py
View
24 src/flask_assets.py
@@ -196,6 +196,22 @@ def resolve_source_to_url(self, filepath, item):
if self.use_webassets_system_for_sources:
return super(FlaskResolver, self).resolve_source_to_url(filepath, item)
+ return self.convert_item_to_flask_url(item)
+
+ def resolve_output_to_url(self, target):
+ # With a directory/url pair set, use it for output files.
+ if self.use_webassets_system_for_output:
+ return Resolver.resolve_output_to_url(self, target)
+
+ # Otherwise, behaves like all other flask URLs.
+ return self.convert_item_to_flask_url(target)
+
+ def convert_item_to_flask_url(self, item):
+ """Given a relative reference like `foo/bar.css`, returns
+ the Flask static url. By doing so it takes into account
+ blueprints, i.e. in the aformentioned example,
+ ``foo`` may reference a blueprint.
+ """
filename = item
if hasattr(self.env._app, 'blueprints'):
try:
@@ -225,14 +241,6 @@ def resolve_source_to_url(self, filepath, item):
if ctx:
ctx.pop()
- def resolve_output_to_url(self, target):
- # With a directory/url pair set, use it for output files.
- if self.use_webassets_system_for_output:
- return Resolver.resolve_output_to_url(self, target)
-
- # Otherwise, behaves like generating urls to a source file.
- return self.resolve_source_to_url(None, target)
-
class Environment(BaseEnvironment):
View
6 tests/test_integration.py
@@ -99,6 +99,12 @@ def test_custom_load_path(self):
assert Bundle('foo').urls(self.env) == ['/custom/foo']
assert Bundle('module/bar').urls(self.env) == ['/custom/module/bar']
+ # [Regression] With a load path configured, generating output
+ # urls still works, and it still uses the flask system.
+ self.env.debug = False
+ self.env.url_expire = False
+ assert Bundle('foo', output='out').urls(self.env) == ['/app_static/out']
+
def test_custom_directory_and_url(self):
"""Custom directory/url are configured - this will affect how
we deal with output files."""
Please sign in to comment.
Something went wrong with that request. Please try again.