From 42104fe288b5559ac0db8884d67a18cae1f6fc20 Mon Sep 17 00:00:00 2001 From: Erik Taubeneck Date: Sat, 26 Oct 2013 18:03:24 -0400 Subject: [PATCH] config-default: check for app.debug in init_app rather than each call to url_for --- flask_s3.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flask_s3.py b/flask_s3.py index 711f390..20637bc 100644 --- a/flask_s3.py +++ b/flask_s3.py @@ -29,9 +29,6 @@ def url_for(endpoint, **values): if 'S3_BUCKET_NAME' not in app.config: raise ValueError("S3_BUCKET_NAME not found in app configuration.") - if app.debug and not app.config['USE_S3_DEBUG']: - return flask_url_for(endpoint, **values) - if endpoint == 'static' or endpoint.endswith('.static'): scheme = 'http' if app.config['S3_USE_HTTPS']: @@ -228,6 +225,9 @@ class FlaskS3(object): for k, v in defaults: app.config.setdefault(k, v) + if app.debug and not app.config['USE_S3_DEBUG']: + app.config['USE_S3'] = False + if app.config['USE_S3']: app.jinja_env.globals['url_for'] = url_for if app.config['S3_USE_CACHE_CONTROL'] and 'S3_CACHE_CONTROL' in app.config: