fixed some problems with admin no GAE, still readonly

This commit is contained in:
mdipierro
2012-08-29 15:09:08 -05:00
parent b5809db9eb
commit a40b55d8d4
6 changed files with 21 additions and 11 deletions
+7 -5
View File
@@ -51,12 +51,12 @@ def log_progress(app,mode='EDIT',filename=None,progress=0):
progress_file = os.path.join(apath(app, r=request), 'progress.log')
now = str(request.now)[:19]
if not os.path.exists(progress_file):
open(progress_file,'w').write('[%s] START\n' % now)
safe_open(progress_file,'w').write('[%s] START\n' % now)
if filename:
open(progress_file,'a').write('[%s] %s %s: %s\n' % (now,mode,filename,progress))
safe_open(progress_file,'a').write('[%s] %s %s: %s\n' % (now,mode,filename,progress))
def safe_open(a,b):
if DEMO_MODE and 'w' in b:
if DEMO_MODE and ('w' in b or 'a' in b):
class tmp:
def write(self,data): pass
return tmp()
@@ -455,11 +455,13 @@ def delete():
def enable():
app = get_app()
filename = os.path.join(apath(app, r=request),'DISABLED')
if os.path.exists(filename):
if is_gae:
return SPAN(T('Not supported'),_style='color:yellow')
elif os.path.exists(filename):
os.unlink(filename)
return SPAN(T('Disable'),_style='color:green')
else:
open(filename,'wb').write(time.ctime())
safe_open(filename,'wb').write(time.ctime())
return SPAN(T('Enable'),_style='color:red')
def peek():
+4 -1
View File
@@ -12,6 +12,9 @@ if request.env.web2py_runtime_gae:
session_db = DAL('gae')
session.connect(request, response, db=session_db)
hosts = (http_host, )
is_gae = True
else:
is_gae = False
if request.env.http_x_forwarded_for or request.is_https:
session.secure()
@@ -27,7 +30,7 @@ try:
raise HTTP(200, T('admin disabled because no admin password'))
except IOError:
import gluon.fileutils
if request.env.web2py_runtime_gae:
if is_gae:
if gluon.fileutils.check_credentials(request):
session.authorized = True
session.last_time = time.time()