Skip to content

Commit

Permalink
webassets now requires us to implement __contains__. This fixes a
Browse files Browse the repository at this point in the history
problem in which existing Flask config values could be overridden with
their Flask-Assets defaults.
  • Loading branch information
miracle2k committed Aug 21, 2010
1 parent 09e5764 commit a0f7f51
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/flaskext/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ def _transform_key(self, key):
else:
return key.upper()

def __contains__(self, key):
return self._transform_key(key) in self.env.app.config

def __getitem__(self, key):
return self.env.app.config[self._transform_key(key)]

Expand Down
10 changes: 10 additions & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,13 @@ def test_custom_values(self):
"""
self.app.config['LESS_PATH'] = '/usr/bin/less'
assert self.env.config['LESS_PATH'] == '/usr/bin/less'

def test_no_override(self):
"""Ensure that the webassets defaults do not override existing
Flask config values.
"""
app = Flask(__name__)
app.config['ASSETS_UPDATER'] = 'MOO'
env = Environment(app)
assert env.updater == 'MOO'
assert app.config['ASSETS_UPDATER'] == 'MOO'

0 comments on commit a0f7f51

Please sign in to comment.