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: 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) 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) 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)) 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) 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) 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 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)