mirror of
https://github.com/wassname/flask-s3.git
synced 2026-09-09 11:22:32 +08:00
config-default: check for app.debug in init_app rather than each call to url_for
This commit is contained in:
+3
-3
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user