From a23a068d40b14ffe84efa054b55e1fe5b73faba4 Mon Sep 17 00:00:00 2001 From: jvanbraekel <29703119+jvanbraekel@users.noreply.github.com> Date: Tue, 23 Jul 2019 15:52:21 +0200 Subject: [PATCH 1/5] Add utf-8 encoding in latex log opening By default, open use ascii encoding leading to crash when non ascii caracters are present . Fix it by enforcing UTF-8 encoding --- gluon/contrib/markmin/markmin2pdf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gluon/contrib/markmin/markmin2pdf.py b/gluon/contrib/markmin/markmin2pdf.py index 7e3c2eec..299cb1dc 100644 --- a/gluon/contrib/markmin/markmin2pdf.py +++ b/gluon/contrib/markmin/markmin2pdf.py @@ -80,7 +80,7 @@ def latex2pdf(latex, pdflatex='pdflatex', passes=3): outfile.close() re_errors = re.compile('^\!(.*)$', re.M) re_warnings = re.compile('^LaTeX Warning\:(.*)$', re.M) - flog = open(logname) + flog = open(logname,encoding="utf-8") try: loglines = flog.read() finally: From 251314ceb89ed63c6fd7a84f76071d26432bf8da Mon Sep 17 00:00:00 2001 From: jvanbraekel <29703119+jvanbraekel@users.noreply.github.com> Date: Wed, 24 Jul 2019 09:43:03 +0200 Subject: [PATCH 2/5] Only return get_vars after a failing login Since the redirect is a GET action, there is no reason to return post vars from the failing attempt. --- gluon/tools.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/gluon/tools.py b/gluon/tools.py index aefebbc5..e6421b88 100644 --- a/gluon/tools.py +++ b/gluon/tools.py @@ -2638,9 +2638,7 @@ class Auth(AuthAPI): # invalid login session.flash = specific_error if self.settings.login_specify_error else self.messages.invalid_login callback(onfail, None) - if 'password' in request.post_vars: - del request.post_vars['password'] - redirect(self.url(args=request.args, vars=request.vars),client_side=settings.client_side) + redirect(self.url(args=request.args, vars=request.get_vars),client_side=settings.client_side) else: # use a central authentication server cas = settings.login_form From 37d1fca32c9ab5571ef29401405d0f479f413a11 Mon Sep 17 00:00:00 2001 From: jvanbraekel <29703119+jvanbraekel@users.noreply.github.com> Date: Thu, 25 Jul 2019 11:28:37 +0200 Subject: [PATCH 3/5] Enable greek symbols support Pakage was missing form the template, leading to errors when greeks characters were used --- gluon/contrib/markmin/markmin2latex.py | 1 + 1 file changed, 1 insertion(+) diff --git a/gluon/contrib/markmin/markmin2latex.py b/gluon/contrib/markmin/markmin2latex.py index 8f37e8bb..643e83d5 100755 --- a/gluon/contrib/markmin/markmin2latex.py +++ b/gluon/contrib/markmin/markmin2latex.py @@ -237,6 +237,7 @@ WRAPPER = """ \\usepackage{graphicx} \\usepackage{grffile} \\usepackage[utf8x]{inputenc} +\\usepackage{textgreek} \\definecolor{lg}{rgb}{0.9,0.9,0.9} \\definecolor{dg}{rgb}{0.3,0.3,0.3} \\def\\ft{\\small\\tt} From b4c2ee830429a8c1e2f14d3612e4671f6b40233b Mon Sep 17 00:00:00 2001 From: Dinis Date: Thu, 25 Jul 2019 17:15:19 +0100 Subject: [PATCH 4/5] Allow easily switching fake_migrate on to allow easier fixes of the database migrations --- gluon/console.py | 6 ++++++ gluon/shell.py | 4 +++- gluon/widget.py | 3 ++- scripts/migrator.py | 4 +++- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/gluon/console.py b/gluon/console.py index 624941a7..10cf5a23 100644 --- a/gluon/console.py +++ b/gluon/console.py @@ -266,6 +266,12 @@ web2py will attempt to run a GUI to ask for it when starting the web server '(default is %(default)s), see -S above. NOTE: when the APP_ENV ' 'argument of -S include a controller c automatic import of ' 'models is always enabled') + g.add_argument('--fake_migrate', + default=False, + action='store_true', + help= + 'force DAL to fake migrate all tables; ' + 'monkeypatch in the DAL class to force _fake_migrate=True') g.add_argument('--force_migrate', '--force-migrate', default=False, action='store_true', help= diff --git a/gluon/shell.py b/gluon/shell.py index f8de2abd..f249c341 100644 --- a/gluon/shell.py +++ b/gluon/shell.py @@ -217,7 +217,8 @@ def run( python_code=None, cron_job=False, scheduler_job=False, - force_migrate=False): + force_migrate=False, + fake_migrate=False): """ Start interactive shell or run Python script (startfile) in web2py controller environment. appname is formatted like: @@ -255,6 +256,7 @@ def run( def custom_init(*args, **kwargs): kwargs['migrate_enabled'] = True kwargs['migrate'] = True + kwargs['fake_migrate'] = fake_migrate logger.info('Forcing migrate_enabled=True') orig_init(*args, **kwargs) diff --git a/gluon/widget.py b/gluon/widget.py index b41974ff..98d6791d 100644 --- a/gluon/widget.py +++ b/gluon/widget.py @@ -741,7 +741,8 @@ def start(): sys.argv = [options.run or ''] + options.args run(options.shell, plain=options.plain, bpython=options.bpython, import_models=options.import_models, startfile=options.run, - cron_job=options.cron_job, force_migrate=options.force_migrate) + cron_job=options.cron_job, force_migrate=options.force_migrate, + fake_migrate=options.fake_migrate) return # set size of cron thread pools diff --git a/scripts/migrator.py b/scripts/migrator.py index d94c5fa6..6f9c9a65 100644 --- a/scripts/migrator.py +++ b/scripts/migrator.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- ''' To use, e.g. python .\web2py.py -S APPNAME --force_migrate +To use, e.g. python .\web2py.py -S APPNAME --force_migrate --fake_migrate ''' import logging @@ -31,5 +32,6 @@ for db_name in databases: for table_name in tables: # Force migration of lazy tables logger.debug("Ensuring migration of table '%s'", table_name) - db(db[table_name]).isempty() + table = db[table_name] + db(table).isempty() db.commit() From 179edb659a14f97c7ceb6f5d28219daf9d4a969d Mon Sep 17 00:00:00 2001 From: Dinis Date: Tue, 13 Aug 2019 18:04:30 +0100 Subject: [PATCH 5/5] Load all models when using --force_migrate (same behaviour as appadmin). --- gluon/shell.py | 1 + 1 file changed, 1 insertion(+) diff --git a/gluon/shell.py b/gluon/shell.py index f249c341..fe94692c 100644 --- a/gluon/shell.py +++ b/gluon/shell.py @@ -249,6 +249,7 @@ def run( fileutils.create_app(adir) if force_migrate: + c = 'appadmin' # Load all models (hack already used for appadmin controller) import_models = True from gluon.dal import DAL orig_init = DAL.__init__