1
0
forked from ScoDoc/ScoDoc

Corrige calcul URL "zope compatibles" en http/https en mode production

This commit is contained in:
Emmanuel Viennet 2021-08-27 18:17:45 +02:00
parent fc3e7ba079
commit 9fb8796e0d
3 changed files with 11 additions and 6 deletions

View File

@ -41,13 +41,15 @@ class ZRequest(object):
"Emulating Zope 2 REQUEST" "Emulating Zope 2 REQUEST"
def __init__(self): def __init__(self):
self.URL = request.base_url if current_app.config["DEBUG"]:
self.URL = request.base_url
self.BASE0 = request.url_root
else:
self.URL = request.base_url.replace("http://", "https://")
self.BASE0 = request.url_root.replace("http://", "https://")
self.URL0 = self.URL self.URL0 = self.URL
self.BASE0 = request.url_root # query_string is bytes:
self.QUERY_STRING = request.query_string.decode( self.QUERY_STRING = request.query_string.decode("utf-8")
"utf-8"
) # query_string is bytes
self.REQUEST_METHOD = request.method self.REQUEST_METHOD = request.method
self.AUTHENTICATED_USER = current_user self.AUTHENTICATED_USER = current_user
self.REMOTE_ADDR = request.remote_addr self.REMOTE_ADDR = request.remote_addr

View File

@ -37,6 +37,7 @@ import flask
from flask import url_for from flask import url_for
from flask import g from flask import g
from flask_login import current_user from flask_login import current_user
from flask import request
from app.scodoc.notes_log import log, logCallStack from app.scodoc.notes_log import log, logCallStack
import app.scodoc.sco_utils as scu import app.scodoc.sco_utils as scu

View File

@ -45,6 +45,7 @@ class ProdConfig(Config):
SQLALCHEMY_DATABASE_URI = ( SQLALCHEMY_DATABASE_URI = (
os.environ.get("SCODOC_DATABASE_URI") or "postgresql:///SCODOC" os.environ.get("SCODOC_DATABASE_URI") or "postgresql:///SCODOC"
) )
PREFERRED_URL_SCHEME = "https"
class DevConfig(Config): class DevConfig(Config):
@ -59,6 +60,7 @@ class DevConfig(Config):
class TestConfig(DevConfig): class TestConfig(DevConfig):
TESTING = True TESTING = True
DEBUG = True
SQLALCHEMY_DATABASE_URI = ( SQLALCHEMY_DATABASE_URI = (
os.environ.get("SCODOC_TEST_DATABASE_URI") or "postgresql:///SCODOC_TEST" os.environ.get("SCODOC_TEST_DATABASE_URI") or "postgresql:///SCODOC_TEST"
) )