Environment().init_app(app) throws RuntimeError
rhymiz opened this issue · comments
assets_env = Environment()
assets_env.init_app(app)
assets_env.load_path = [paths]
throws:
Traceback (most recent call last):
File "run.py", line 1, in <module>
from app import app
File "/Users/lemuel.boyce/Documents/Projects/someapp/app/__init__.py", line 90, in <module>
os.path.join(app.config['BASE_DIRECTORY'], 'app/static/coffee')
File "/Users/lemuel.boyce/pyvenv/lib/python2.7/site-packages/webassets/env.py", line 657, in _set_load_path
self._storage['load_path'] = load_path
File "/Users/lemuel.boyce/pyvenv/lib/python2.7/site-packages/flask_assets.py", line 112, in __setitem__
self.env._app.config[self._transform_key(key)] = value
File "/Users/lemuel.boyce/pyvenv/lib/python2.7/site-packages/flask_assets.py", line 330, in _app
'and no application in current context')
RuntimeError: assets instance not bound to an application, and no application in current context
while assets_env = Environment(app)
works just fine
That's working as expected.
If you use the init_app()
syntax, you need to have a Flask application on the stack; the purpose of this approach is that it should work with more than one app. Otherwise, if you do:
assets_env.load_path = [paths]
it doesn't know which app config to modify.