[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-taler-merchant-demos] branch master updated: -try with url_for
From: |
gnunet |
Subject: |
[taler-taler-merchant-demos] branch master updated: -try with url_for |
Date: |
Wed, 07 Sep 2022 15:00:49 +0200 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository taler-merchant-demos.
The following commit(s) were added to refs/heads/master by this push:
new e0a686c -try with url_for
e0a686c is described below
commit e0a686ccd7fc249c935a5dee43f0551d457bb9c1
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Wed Sep 7 15:00:46 2022 +0200
-try with url_for
---
talermerchantdemos/blog/blog.py | 15 +++++++--------
talermerchantdemos/httpcommon/__init__.py | 2 +-
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/talermerchantdemos/blog/blog.py b/talermerchantdemos/blog/blog.py
index c1641d6..7eb219a 100644
--- a/talermerchantdemos/blog/blog.py
+++ b/talermerchantdemos/blog/blog.py
@@ -24,7 +24,7 @@ import traceback
import uuid
import base64
import flask
-from flask import request
+from flask import request, url_for
from flask_babel import Babel
from flask_babel import refresh
from flask_babel import force_locale
@@ -36,7 +36,6 @@ from urllib.parse import urljoin, urlencode, urlparse
from taler.util.talerconfig import TalerConfig, ConfigurationError
from ..blog.content import ARTICLES, get_article_file, get_image_file
from talermerchantdemos.httpcommon import (
- get_app_root,
backend_get,
backend_post,
self_localized,
@@ -137,9 +136,9 @@ def internal_error(e):
# @return response object of the index page.
@app.route("/")
def index():
- default = "/en"
+ default = "en"
target = flask.request.accept_languages.best_match(translations, default)
- return flask.redirect(get_app_root() + "/" + target + "/", code=302)
+ return flask.redirect(url_for (target + "/"), code=302)
##
@@ -395,12 +394,12 @@ def article(article_name, lang=None, data=None):
response.set_cookie(
"order_id",
ai,
- path=urllib.parse.quote(get_app_root() + f"/essay/{article_name}")
+ path=urllib.parse.quote(url_for(f"essay/{article_name}"))
)
response.set_cookie(
"order_id",
ai,
- path=urllib.parse.quote(get_app_root() +
f"/{lang}/essay/{article_name}")
+ path=urllib.parse.quote(url_for(f"{lang}/essay/{article_name}"))
)
return response
@@ -414,12 +413,12 @@ def article(article_name, lang=None, data=None):
response.set_cookie(
"order_id",
order_id,
- path=urllib.parse.quote(get_app_root() + f"/essay/{article_name}")
+ path=urllib.parse.quote(url_for (f"essay/{article_name}"))
)
response.set_cookie(
"order_id",
order_id,
- path=urllib.parse.quote(get_app_root() +
f"/{lang}/essay/{article_name}")
+ path=urllib.parse.quote(url_for (f"{lang}/essay/{article_name}"))
)
return response
diff --git a/talermerchantdemos/httpcommon/__init__.py
b/talermerchantdemos/httpcommon/__init__.py
index ca61b66..cddc96a 100644
--- a/talermerchantdemos/httpcommon/__init__.py
+++ b/talermerchantdemos/httpcommon/__init__.py
@@ -195,7 +195,7 @@ def make_utility_processor(pagename):
getlang=getlang,
all_languages=all_languages,
static=static,
- script_name=request.environ.get("SCRIPT_NAME", ""),
+ script_name=get_app_root(),
)
return utility_processor
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-taler-merchant-demos] branch master updated: -try with url_for,
gnunet <=
- [taler-taler-merchant-demos] branch master updated: -try with url_for, gnunet, 2022/09/07
- [taler-taler-merchant-demos] branch master updated: -try with url_for, gnunet, 2022/09/07
- [taler-taler-merchant-demos] branch master updated: -try with url_for, gnunet, 2022/09/07
- [taler-taler-merchant-demos] branch master updated: -try with url_for, gnunet, 2022/09/07
- [taler-taler-merchant-demos] branch master updated: -try with url_for, gnunet, 2022/09/07