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
+1 -1
View File
@@ -1 +1 @@
Version 2.00.1 (2012-08-29 10:27:58) rc4
Version 2.00.1 (2012-08-29 15:09:03) rc4
+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()
+4 -2
View File
@@ -14,6 +14,7 @@ FOR INTERNAL USE ONLY
import os
import thread
import logging
from fileutils import read_file
cfs = {} # for speed-up
@@ -34,15 +35,16 @@ def getcfs(key, filename, filter=None):
This is used on Google App Engine since pyc files cannot be saved.
"""
try:
logging.info(filename)
t = os.stat(filename).st_mtime
except OSError:
return filter()
return filter() if callable(filter) else ''
cfs_lock.acquire()
item = cfs.get(key, None)
cfs_lock.release()
if item and item[0] == t:
return item[1]
if not filter:
if not callable(filter):
data = read_file(filename)
else:
data = filter()
+1 -1
View File
@@ -4329,9 +4329,9 @@ class GoogleDatastoreAdapter(NoSQLAdapter):
def select_raw(self,query,fields=None,attributes=None):
db = self.db
args_get = attributes.get
fields = fields or []
attributes = attributes or {}
args_get = attributes.get
new_fields = []
for item in fields:
if isinstance(item,SQLALL):
+4 -1
View File
@@ -429,7 +429,10 @@ class translator(object):
self.request = request
self.folder = request.folder
self.langpath = ospath.join(self.folder,'languages')
self.filenames = set(os.listdir(self.langpath))
try:
self.filenames = set(os.listdir(self.langpath))
except:
self.filenames = set()
self.http_accept_language = request.env.http_accept_language
# self.cache # filled in self.force()
# self.accepted_language = None # filled in self.force()