Compare commits

..

1 Commits

Author SHA1 Message Date
Dinis
6fddca4e4f Force page reload with anchors
Force page to reload even when the location contains anchors, while using "web2py-redirect-location".
Otherwise, when the location is the same and the url has an anchor it won't redirect.
2019-07-17 15:18:44 +01:00
6 changed files with 5 additions and 16 deletions

View File

@@ -284,6 +284,7 @@
var redirect = xhr.getResponseHeader('web2py-redirect-location');
if (redirect !== null) {
window.location = redirect;
window.location.reload(); // Force reload even with anchors
}
/* run this here only if this Ajax request is NOT for a web2py component. */
if (xhr.getResponseHeader('web2py-component-content') === null) {

View File

@@ -266,12 +266,6 @@ 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=

View File

@@ -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 = 'https' if request and request.is_https else 'http'
scheme = request.env.get('wsgi_url_scheme', 'http').lower() if request 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)

View File

@@ -217,8 +217,7 @@ def run(
python_code=None,
cron_job=False,
scheduler_job=False,
force_migrate=False,
fake_migrate=False):
force_migrate=False):
"""
Start interactive shell or run Python script (startfile) in web2py
controller environment. appname is formatted like:
@@ -249,7 +248,6 @@ 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__
@@ -257,7 +255,6 @@ 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)

View File

@@ -741,8 +741,7 @@ 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,
fake_migrate=options.fake_migrate)
cron_job=options.cron_job, force_migrate=options.force_migrate)
return
# set size of cron thread pools

View File

@@ -1,7 +1,6 @@
# -*- 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
@@ -32,6 +31,5 @@ for db_name in databases:
for table_name in tables:
# Force migration of lazy tables
logger.debug("Ensuring migration of table '%s'", table_name)
table = db[table_name]
db(table).isempty()
db(db[table_name]).isempty()
db.commit()