Replaced config SCHEME with Flask's own PREFERRED_URL_SCHEME setting.

This prevents us from explicitly passing SCHEME to url_for() calls.

NOTE: this possibly requires an update to your config_local.py
This commit is contained in:
Sybren A. Stüvel 2017-08-31 14:37:35 +02:00
parent d6dd0d69d0
commit 8318d4b1f6
5 changed files with 6 additions and 10 deletions

View File

@ -364,8 +364,7 @@ def generate_link(backend, file_path: str, project_id=None, is_public=False) ->
return blob.get_url(is_public=is_public)
if backend == 'pillar':
return url_for('file_storage.index', file_name=file_path,
_external=True, _scheme=current_app.config['SCHEME'])
return url_for('file_storage.index', file_name=file_path, _external=True)
if backend == 'cdnsun':
return hash_file_path(file_path, None)
if backend == 'unittest':

View File

@ -34,7 +34,7 @@ class LocalBucket(Bucket):
def copy_blob(self, blob: Blob, to_bucket: Bucket):
"""Copies a blob from the current bucket to the other bucket.
Implementations only need to support copying between buckets of the
same storage backend.
"""
@ -73,8 +73,7 @@ class LocalBlob(Blob):
from flask import url_for
path = self.bucket.bucket_path / self.partial_path
url = url_for('file_storage.index', file_name=str(path), _external=True,
_scheme=current_app.config['SCHEME'])
url = url_for('file_storage.index', file_name=str(path), _external=True)
return url
def create_from_file(self, file_obj: FileType, *,

View File

@ -74,8 +74,7 @@ class OAuthSignIn(metaclass=abc.ABCMeta):
pass
def get_callback_url(self):
return url_for('users.oauth_callback', provider=self.provider_name,
_external=True, _scheme=current_app.config['SCHEME'])
return url_for('users.oauth_callback', provider=self.provider_name, _external=True)
@staticmethod
def auth_code_from_request() -> str:

View File

@ -12,7 +12,7 @@ import requests.certs
RFC1123_DATE_FORMAT = '%a, %d %b %Y %H:%M:%S GMT'
PILLAR_SERVER_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SCHEME = 'https'
PREFERRED_URL_SCHEME = 'https'
STORAGE_DIR = getenv('PILLAR_STORAGE_DIR', '/data/storage/pillar')
PORT = 5000
HOST = '0.0.0.0'

View File

@ -412,8 +412,7 @@ def edit(node_id):
else:
project_update_nodes_list(node, project_id=project._id)
return redirect(url_for('nodes.view', node_id=node_id, embed=1,
_external=True,
_scheme=current_app.config['SCHEME']))
_external=True))
else:
log.debug('Error sending data to Pillar, see Pillar logs.')
error = 'Server error'