From c82f0ba61903bc4e11738e70b7b1625d69b5993e Mon Sep 17 00:00:00 2001 From: web-py <40534181+web-py@users.noreply.github.com> Date: Sun, 2 Jun 2019 16:07:58 +0430 Subject: [PATCH 1/8] Update fa.py edit plural-forms for persian agian --- gluon/contrib/plural_rules/fa.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gluon/contrib/plural_rules/fa.py b/gluon/contrib/plural_rules/fa.py index 8b137891..35de411c 100644 --- a/gluon/contrib/plural_rules/fa.py +++ b/gluon/contrib/plural_rules/fa.py @@ -1 +1,4 @@ +#!/usr/bin/env python +# -*- coding: utf8 -*- +# Plural-Forms for fa (Persian) From 2a7b16d61f77cf942c23f503de6fbdf7d87ff1a6 Mon Sep 17 00:00:00 2001 From: Lisandro Date: Fri, 7 Jun 2019 19:21:10 -0300 Subject: [PATCH 2/8] Added followlinks argument to listdir The followlinks argument is then used by the function when it calls os.walk(path... Notice the "followlinks" argument of os.walk() is False by default, so this change won't make any difference. Every actual call to listdir() function won't need to be changed. This change is needed to resolve issue #2221 --- gluon/fileutils.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gluon/fileutils.py b/gluon/fileutils.py index f6af6fea..764a8e7b 100644 --- a/gluon/fileutils.py +++ b/gluon/fileutils.py @@ -148,7 +148,8 @@ def listdir(path, add_dirs=False, sort=True, maxnum=None, - exclude_content_from=None + exclude_content_from=None, + followlinks=False ): """ Like `os.listdir()` but you can specify a regex pattern to filter files. @@ -164,7 +165,7 @@ def listdir(path, n = 0 regex = re.compile(expression) items = [] - for (root, dirs, files) in os.walk(path, topdown=True): + for (root, dirs, files) in os.walk(path, topdown=True, followlinks=followlinks): for dir in dirs[:]: if dir.startswith('.'): dirs.remove(dir) From 2989beae023eb5959a40b785e75662fe4f8feb19 Mon Sep 17 00:00:00 2001 From: Lisandro Date: Fri, 7 Jun 2019 19:24:59 -0300 Subject: [PATCH 3/8] Added followlinks=True when calling listdir In order to solve the issue #2221, I've added followlinks=True when calling listdir() from functions compile_views(), compile_models() and compile_controllers() --- gluon/compileapp.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gluon/compileapp.py b/gluon/compileapp.py index cde7ee3b..cbc41518 100644 --- a/gluon/compileapp.py +++ b/gluon/compileapp.py @@ -437,7 +437,7 @@ def compile_views(folder, skip_failed_views=False): """ path = pjoin(folder, 'views') failed_views = [] - for fname in listdir(path, REGEX_VIEW_PATH): + for fname in listdir(path, REGEX_VIEW_PATH, followlinks=True): try: data = parse_template(fname, path) except Exception as e: @@ -462,7 +462,7 @@ def compile_models(folder): Compiles all the models in the application specified by `folder` """ path = pjoin(folder, 'models') - for fname in listdir(path, REGEX_MODEL_PATH): + for fname in listdir(path, REGEX_MODEL_PATH, followlinks=True): data = read_file(pjoin(path, fname)) modelfile = 'models.'+fname.replace(os.sep, '.') filename = pjoin(folder, 'compiled', modelfile) @@ -487,7 +487,7 @@ def compile_controllers(folder): Compiles all the controllers in the application specified by `folder` """ path = pjoin(folder, 'controllers') - for fname in listdir(path, REGEX_CONTROLLER): + for fname in listdir(path, REGEX_CONTROLLER, followlinks=True): data = read_file(pjoin(path, fname)) exposed = find_exposed_functions(data) for function in exposed: From f8454974794bae56fa52cc88ceb06a52aa88f02c Mon Sep 17 00:00:00 2001 From: Nico Zanferrari Date: Sun, 7 Jul 2019 00:55:39 +0200 Subject: [PATCH 4/8] fix for py 3.6+ compatibility py 3.6+ gives errors and need more escapes - I've tested the patch on the full web2py book's latex output and it's backward compatible with 2.7. For technical details see https://bugs.python.org/issue28450 : "Deprecated since version 3.5, will be removed in version 3.6: Unknown escapes consist of '\' and ASCII letter now raise a deprecation warning and will be forbidden in Python 3.6" --- gluon/contrib/markmin/markmin2latex.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/gluon/contrib/markmin/markmin2latex.py b/gluon/contrib/markmin/markmin2latex.py index ce1fe1d1..8f37e8bb 100755 --- a/gluon/contrib/markmin/markmin2latex.py +++ b/gluon/contrib/markmin/markmin2latex.py @@ -18,14 +18,14 @@ regex_title = re.compile('^#{1} (?P[^\n]+)', re.M) regex_maps = [ (re.compile('[ \t\r]+\n'), '\n'), (re.compile('\*\*(?P[^\s\*]+( +[^\s\*]+)*)\*\*'), '{\\\\bf \g}'), - (re.compile("''(?P[^\s']+( +[^\s']+)*)''"), '{\\it \g}'), + (re.compile("''(?P[^\s']+( +[^\s']+)*)''"), '{\\\it \g}'), (re.compile('^#{5,6}\s*(?P[^\n]+)', re.M), '\n\n{\\\\bf \g}\n'), - (re.compile('^#{4}\s*(?P[^\n]+)', re.M), '\n\n\\\\goodbreak\\subsubsection{\g}\n'), - (re.compile('^#{3}\s*(?P[^\n]+)', re.M), '\n\n\\\\goodbreak\\subsection{\g}\n'), - (re.compile('^#{2}\s*(?P[^\n]+)', re.M), '\n\n\\\\goodbreak\\section{\g}\n'), + (re.compile('^#{4}\s*(?P[^\n]+)', re.M), '\n\n\\\\goodbreak\\\subsubsection{\g}\n'), + (re.compile('^#{3}\s*(?P[^\n]+)', re.M), '\n\n\\\\goodbreak\\\subsection{\g}\n'), + (re.compile('^#{2}\s*(?P[^\n]+)', re.M), '\n\n\\\\goodbreak\\\section{\g}\n'), (re.compile('^#{1}\s*(?P[^\n]+)', re.M), ''), - (re.compile('^\- +(?P.*)', re.M), '\\\\begin{itemize}\n\\item \g\n\\end{itemize}'), - (re.compile('^\+ +(?P.*)', re.M), '\\\\begin{itemize}\n\\item \g\n\\end{itemize}'), + (re.compile('^\- +(?P.*)', re.M), '\\\\begin{itemize}\n\\\item \g\n\\\end{itemize}'), + (re.compile('^\+ +(?P.*)', re.M), '\\\\begin{itemize}\n\\\item \g\n\\\end{itemize}'), (re.compile('\\\\end\{itemize\}\s+\\\\begin\{itemize\}'), '\n'), (re.compile('\n\s+\n'), '\n\n')] regex_table = re.compile('^\-{4,}\n(?P.*?)\n\-{4,}(:(?P\w+))?\n', re.M | re.S) @@ -97,7 +97,7 @@ def render(text, text = latex_escape(text, pound=False) texts = text.split('## References', 1) - text = regex_anchor.sub('\\label{\g}', texts[0]) + text = regex_anchor.sub('\\\label{\g}', texts[0]) if len(texts) == 2: text += '\n\\begin{thebibliography}{999}\n' text += regex_bibitem.sub('\n\\\\bibitem{\g}', texts[1]) @@ -145,7 +145,7 @@ def render(text, text = regex_image_width.sub(sub, text) text = regex_image.sub(sub, text) - text = regex_link.sub('{\\\\footnotesize\\href{\g}{\g}}', text) + text = regex_link.sub('{\\\\footnotesize\\\href{\g}{\g}}', text) text = regex_commas.sub('\g', text) text = regex_noindent.sub('\n\\\\noindent \g', text) From f307fe7d56b8948058032a9974ebc937e45c375c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonel=20C=C3=A2mara?= Date: Wed, 10 Jul 2019 12:25:40 +0100 Subject: [PATCH 5/8] __lt__ and __gt__ for lazyT Fixes #2228 --- gluon/languages.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gluon/languages.py b/gluon/languages.py index 6262500b..9ed60f9c 100644 --- a/gluon/languages.py +++ b/gluon/languages.py @@ -392,6 +392,12 @@ class lazyT(object): def __eq__(self, other): return str(self) == str(other) + def __lt__(self, other): + return str(self) < str(other) + + def __gt__(self, other): + return str(self) > str(other) + def __ne__(self, other): return str(self) != str(other) From 9db1c6b0b0ff1c73659630275961e0b648f4dd46 Mon Sep 17 00:00:00 2001 From: "Bryan A. Jones" Date: Fri, 12 Jul 2019 10:23:53 -0500 Subject: [PATCH 6/8] Allow specification of server's encoding in webclient. --- gluon/contrib/webclient.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/gluon/contrib/webclient.py b/gluon/contrib/webclient.py index beac2ff9..f2d75969 100644 --- a/gluon/contrib/webclient.py +++ b/gluon/contrib/webclient.py @@ -64,7 +64,7 @@ class WebClient(object): headers=headers, method='GET') def post(self, url, data=None, cookies=None, - headers=None, auth=None, method='auto'): + headers=None, auth=None, method='auto', charset='utf-8'): self.url = self.app + url # if this POST form requires a postback do it @@ -147,7 +147,11 @@ class WebClient(object): else:#python2.5 self.status = None - self.text = to_native(self.response.read()) + self.text = self.response.read() + if charset: + if charset == 'auto': + charset = self.response.headers.getparam('charset') + self.text = to_native(self.text, charset) # In PY3 self.response.headers are case sensitive self.headers = dict() for h in self.response.headers: @@ -173,9 +177,10 @@ class WebClient(object): self.sessions[name] = value # find all forms and formkeys in page - self.forms = {} - for match in FORM_REGEX.finditer(to_native(self.text)): - self.forms[match.group('formname')] = match.group('formkey') + if charset: + self.forms = {} + for match in FORM_REGEX.finditer(self.text): + self.forms[match.group('formname')] = match.group('formkey') # log this request self.history.append((self.method, self.url, self.status, self.time)) From 0557fe9c58a0df40809ba4f69dd8f4dab4433382 Mon Sep 17 00:00:00 2001 From: mdipierro Date: Mon, 15 Jul 2019 22:02:57 -0700 Subject: [PATCH 7/8] sync --- gluon/packages/dal | 2 +- gluon/packages/yatl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gluon/packages/dal b/gluon/packages/dal index 1fd32c51..54191338 160000 --- a/gluon/packages/dal +++ b/gluon/packages/dal @@ -1 +1 @@ -Subproject commit 1fd32c51338abce26b3c328887cfb513c9a2ce6f +Subproject commit 541913385cb731f2802b3f1b6f744093bb3abdf3 diff --git a/gluon/packages/yatl b/gluon/packages/yatl index dd969365..2eb050b8 160000 --- a/gluon/packages/yatl +++ b/gluon/packages/yatl @@ -1 +1 @@ -Subproject commit dd969365265bf329c73784d989bdaa6de23d9633 +Subproject commit 2eb050b8e251813e905ecbabba839ca578901a3a From 8faa5e2a82f7f70fb1dbb1ad9c1afbdf7467d862 Mon Sep 17 00:00:00 2001 From: Ray Luo Date: Mon, 22 Jul 2019 23:41:23 -0700 Subject: [PATCH 8/8] Better https detection Switch to request.is_https which provides better https detection --- gluon/rewrite.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gluon/rewrite.py b/gluon/rewrite.py index 526e2a10..48c1535b 100644 --- a/gluon/rewrite.py +++ b/gluon/rewrite.py @@ -204,7 +204,7 @@ def url_out(request, environ, application, controller, function, if host is True or (host is None and (scheme or port is not None)): host = request.env.http_host if not scheme or scheme is True: - scheme = request.env.get('wsgi_url_scheme', 'http').lower() if request else 'http' + scheme = 'https' if request and request.is_https else 'http' if host: host_port = host if not port else host.split(':', 1)[0] + ':%s' % port url = '%s://%s%s' % (scheme, host_port, url)