Merge pull request #331 from spametki/master
Enable admin app for GAE (experimental)
This commit is contained in:
@@ -30,10 +30,18 @@ from gluon.languages import (read_possible_languages, read_dict, write_dict,
|
|||||||
read_plural_dict, write_plural_dict)
|
read_plural_dict, write_plural_dict)
|
||||||
|
|
||||||
|
|
||||||
if DEMO_MODE and request.function in ['change_password', 'pack', 'pack_custom','pack_plugin', 'upgrade_web2py', 'uninstall', 'cleanup', 'compile_app', 'remove_compiled_app', 'delete', 'delete_plugin', 'create_file', 'upload_file', 'update_languages', 'reload_routes', 'git_push', 'git_pull']:
|
if DEMO_MODE and request.function in ['change_password', 'pack',
|
||||||
|
'pack_custom','pack_plugin', 'upgrade_web2py', 'uninstall',
|
||||||
|
'cleanup', 'compile_app', 'remove_compiled_app', 'delete',
|
||||||
|
'delete_plugin', 'create_file', 'upload_file', 'update_languages',
|
||||||
|
'reload_routes', 'git_push', 'git_pull', 'install_plugin']:
|
||||||
session.flash = T('disabled in demo mode')
|
session.flash = T('disabled in demo mode')
|
||||||
redirect(URL('site'))
|
redirect(URL('site'))
|
||||||
|
|
||||||
|
if is_gae and request.function in ('edit', 'edit_language',
|
||||||
|
'edit_plurals', 'update_languages', 'create_file', 'install_plugin'):
|
||||||
|
session.flash = T('disabled in GAE mode')
|
||||||
|
redirect(URL('site'))
|
||||||
|
|
||||||
if not is_manager() and request.function in ['change_password', 'upgrade_web2py']:
|
if not is_manager() and request.function in ['change_password', 'upgrade_web2py']:
|
||||||
session.flash = T('disabled in multi user mode')
|
session.flash = T('disabled in multi user mode')
|
||||||
@@ -63,10 +71,12 @@ def log_progress(app, mode='EDIT', filename=None, progress=0):
|
|||||||
|
|
||||||
|
|
||||||
def safe_open(a, b):
|
def safe_open(a, b):
|
||||||
if DEMO_MODE and ('w' in b or 'a' in b):
|
if (DEMO_MODE or is_gae) and ('w' in b or 'a' in b):
|
||||||
class tmp:
|
class tmp:
|
||||||
def write(self, data):
|
def write(self, data):
|
||||||
pass
|
pass
|
||||||
|
def close(self):
|
||||||
|
pass
|
||||||
return tmp()
|
return tmp()
|
||||||
return open(a, b)
|
return open(a, b)
|
||||||
|
|
||||||
@@ -1496,7 +1506,7 @@ def errors():
|
|||||||
|
|
||||||
app = get_app()
|
app = get_app()
|
||||||
|
|
||||||
method = request.args(1) or 'new'
|
method = request.args(1) or 'new' if not is_gae else "dbnew"
|
||||||
db_ready = {}
|
db_ready = {}
|
||||||
db_ready['status'] = get_ticket_storage(app)
|
db_ready['status'] = get_ticket_storage(app)
|
||||||
db_ready['errmessage'] = T(
|
db_ready['errmessage'] = T(
|
||||||
@@ -1588,7 +1598,7 @@ def errors():
|
|||||||
|
|
||||||
decorated.sort(key=operator.itemgetter(0), reverse=True)
|
decorated.sort(key=operator.itemgetter(0), reverse=True)
|
||||||
|
|
||||||
return dict(errors=[x[1] for x in decorated], app=app, method=method)
|
return dict(errors=[x[1] for x in decorated], app=app, method=method, db_ready=db_ready)
|
||||||
|
|
||||||
elif method == 'dbold':
|
elif method == 'dbold':
|
||||||
tk_db, tk_table = get_ticket_storage(app)
|
tk_db, tk_table = get_ticket_storage(app)
|
||||||
@@ -1601,7 +1611,7 @@ def errors():
|
|||||||
times = dict(
|
times = dict(
|
||||||
[(row.ticket_id, row.created_datetime) for row in tickets_])
|
[(row.ticket_id, row.created_datetime) for row in tickets_])
|
||||||
|
|
||||||
return dict(app=app, tickets=tickets, method=method, times=times)
|
return dict(app=app, tickets=tickets, method=method, times=times, db_ready=db_ready)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
for item in request.vars:
|
for item in request.vars:
|
||||||
@@ -1625,6 +1635,9 @@ def get_ticket_storage(app):
|
|||||||
if os.path.exists(ticket_file):
|
if os.path.exists(ticket_file):
|
||||||
db_string = open(ticket_file).read()
|
db_string = open(ticket_file).read()
|
||||||
db_string = db_string.strip().replace('\r', '').replace('\n', '')
|
db_string = db_string.strip().replace('\r', '').replace('\n', '')
|
||||||
|
elif is_gae:
|
||||||
|
# use Datastore as fallback if there is no ticket_file
|
||||||
|
db_string = "google:datastore"
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
tickets_table = 'web2py_ticket'
|
tickets_table = 'web2py_ticket'
|
||||||
|
|||||||
@@ -65,8 +65,8 @@ skip_files: |
|
|||||||
(.*\.py[co])|
|
(.*\.py[co])|
|
||||||
(.*/RCS/.*)|
|
(.*/RCS/.*)|
|
||||||
(\..*)|
|
(\..*)|
|
||||||
(applications/(admin|examples)/.*)|
|
(applications/examples/.*)|
|
||||||
((admin|examples|welcome)\.(w2p|tar))|
|
((examples|welcome)\.(w2p|tar))|
|
||||||
(applications/.*?/(cron|databases|errors|cache|sessions)/.*)|
|
(applications/.*?/(cron|databases|errors|cache|sessions)/.*)|
|
||||||
((logs|scripts)/.*)|
|
((logs|scripts)/.*)|
|
||||||
(anyserver\.py)|
|
(anyserver\.py)|
|
||||||
|
|||||||
Reference in New Issue
Block a user