From 1a0861d376ae2b22eb575695dfeebaec7d83adc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 26 Nov 2019 22:16:00 +0100 Subject: [PATCH] Add __href__ and is_secure, host and http_host to url module This ease the composition of URL pointing to Tryton route. issue8767 review264461005 --- web.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/web.py b/web.py index b653cfaaeb..8527cd980a 100644 --- a/web.py +++ b/web.py @@ -3,7 +3,7 @@ import string import logging -from urllib.parse import urlunsplit, urljoin, quote +from urllib.parse import urljoin, quote from sql.aggregate import Count @@ -12,14 +12,11 @@ from trytond.model import fields, ModelSQL, ModelView from trytond.pool import Pool from trytond.tools import grouped_slice, reduce_ids from trytond.transaction import Transaction -from trytond.url import HOSTNAME +from trytond.url import http_host from trytond.wsgi import Base64Converter -USE_SSL = bool(config.get('ssl', 'certificate')) ALPHABET = string.digits + string.ascii_lowercase -URL_BASE = config.get('web', 'shortener_base', - default=urlunsplit( - ('http' + ('s' if USE_SSL else ''), HOSTNAME, '', '', ''))) +URL_BASE = config.get('web', 'shortener_base', default=http_host()) logger = logging.getLogger(__name__)