Merge ssh://github.com/web2py/web2py

This commit is contained in:
Michele Comitini
2013-07-27 16:28:10 +02:00
10 changed files with 59 additions and 48 deletions
+1 -1
View File
@@ -1 +1 @@
Version 2.6.0-development+timestamp.2013.07.23.02.04.35
Version 2.6.0-development+timestamp.2013.07.27.06.46.34
+2 -1
View File
@@ -32,7 +32,8 @@ except:
if request.env.http_x_forwarded_for or request.is_https:
session.secure()
elif (remote_addr not in hosts) and (remote_addr != "127.0.0.1"):
elif (remote_addr not in hosts) and (remote_addr != "127.0.0.1") and \
(request.function != 'manage'):
raise HTTP(200, T('appadmin is disabled because insecure channel'))
if request.function == 'manage':
@@ -32,7 +32,8 @@ except:
if request.env.http_x_forwarded_for or request.is_https:
session.secure()
elif (remote_addr not in hosts) and (remote_addr != "127.0.0.1"):
elif (remote_addr not in hosts) and (remote_addr != "127.0.0.1") and \
(request.function != 'manage'):
raise HTTP(200, T('appadmin is disabled because insecure channel'))
if request.function == 'manage':
+2 -1
View File
@@ -32,7 +32,8 @@ except:
if request.env.http_x_forwarded_for or request.is_https:
session.secure()
elif (remote_addr not in hosts) and (remote_addr != "127.0.0.1"):
elif (remote_addr not in hosts) and (remote_addr != "127.0.0.1") and \
(request.function != 'manage'):
raise HTTP(200, T('appadmin is disabled because insecure channel'))
if request.function == 'manage':
File diff suppressed because one or more lines are too long
+9 -2
View File
@@ -679,6 +679,11 @@ class BaseAdapter(ConnectionPool):
'big-reference': 'BIGINT REFERENCES %(foreign_key)s ON DELETE %(on_delete_action)s',
}
def isOperationalError(self,exception):
if not hasattr(self.driver, "OperationalError"):
return None
return isinstance(exception, self.driver.OperationalError)
def id_query(self, table):
return table._id != None
@@ -4324,7 +4329,9 @@ class DatabaseStoredFile:
try:
if db.executesql(query):
return True
except Exception:
except Exception, e:
if not db._adapter.isOperationalError(e):
raise
# no web2py_filesystem found?
tb = traceback.format_exc()
LOGGER.error("Could not retrieve %s\n%s" % (filename, tb))
@@ -5457,7 +5464,7 @@ class MongoDBAdapter(NoSQLAdapter):
else:
mongosort_list.append((f, 1))
if limitby:
limitby_skip, limitby_limit = limitby
limitby_skip, limitby_limit = limitby[0], int(limitby[1])
else:
limitby_skip = limitby_limit = 0
+3
View File
@@ -27,6 +27,7 @@ defined_status = {
307: 'TEMPORARY REDIRECT',
400: 'BAD REQUEST',
401: 'UNAUTHORIZED',
402: 'PAYMENT REQUIRED',
403: 'FORBIDDEN',
404: 'NOT FOUND',
405: 'METHOD NOT ALLOWED',
@@ -79,6 +80,8 @@ class HTTP(Exception):
headers = self.headers
if status in defined_status:
status = '%d %s' % (status, defined_status[status])
elif isinstance(status, int):
status = '%d UNKNOWN ERROR' % status
else:
status = str(status)
if not regex_status.match(status):
+4 -1
View File
@@ -172,7 +172,10 @@ def copystream_progress(request, chunk_size=10 ** 5):
size = int(env.content_length)
except ValueError:
raise HTTP(400, "Invalid Content-Length header")
dest = tempfile.NamedTemporaryFile()
try: # Android requires this
dest = tempfile.NamedTemporaryFile()
except NotImplementedError: # and GAE this
dest = tempfile.TemporaryFile()
if not 'X-Progress-ID' in request.vars:
copystream(source, dest, size, chunk_size)
return dest
+22 -31
View File
@@ -2618,39 +2618,30 @@ class SQLFORM(FORM):
for rfield in table._referenced_by:
check[rfield.tablename] = \
check.get(rfield.tablename, []) + [rfield.name]
if linked_tables is None:
linked_tables = db.tables()
if isinstance(linked_tables, dict):
for tbl in linked_tables.keys():
tb = db[tbl]
if isinstance(linked_tables[tbl], list):
if len(linked_tables[tbl]) > 1:
t = T('%s(%s)' %(tbl, fld))
else:
t = T(tb._plural)
for fld in linked_tables[tbl]:
if fld not in db[tbl].fields:
raise ValueError('Field %s not in table' %fld)
args0 = tbl + '.' + fld
links.append(
lambda row, t=t, nargs=nargs, args0=args0:
A(SPAN(t), _class=trap_class(), _href=url(
args=[args0, row[id_field_name]])))
linked_tables = linked_tables.get(table._tablename,[])
if linked_tables:
for item in linked_tables:
tb = None
if isinstance(item,Table) and item._tablename in check:
tablename = item._tablename
linked_fieldnames = check[tablename]
td = item
elif isinstance(item,str) and item in check:
tablename = item
linked_fieldnames = check[item]
tb = db[item]
elif isinstance(item,Field) and item.name in check.get(item._tablename,[]):
tablename = item._tablename
linked_fieldnames = [item.name]
tb = item.table
else:
t = T(tb._plural)
fld = linked_tables[tbl]
if fld not in db[tbl].fields:
raise ValueError('Field %s not in table' %fld)
args0 = tbl + '.' + fld
links.append(
lambda row, t=t, nargs=nargs, args0=args0:
A(SPAN(t), _class=trap_class(), _href=url(
args=[args0, row[id_field_name]])))
else:
for tablename in sorted(check):
linked_fieldnames = check[tablename]
tb = db[tablename]
multiple_links = len(linked_fieldnames) > 1
for fieldname in linked_fieldnames:
if linked_tables is None or tablename in linked_tables:
linked_fieldnames = []
if tb:
multiple_links = len(linked_fieldnames) > 1
for fieldname in linked_fieldnames:
t = T(tb._plural) if not multiple_links else \
T(tb._plural + '(' + fieldname + ')')
args0 = tablename + '.' + fieldname
+11 -6
View File
@@ -893,6 +893,7 @@ class Auth(object):
on_failed_authentication=lambda x: redirect(x),
formstyle="table3cols",
label_separator=": ",
logging_enabled = True,
allow_delete_accounts=False,
password_field='password',
table_user_name='auth_user',
@@ -969,7 +970,6 @@ class Auth(object):
new_password='New password',
old_password='Old password',
group_description='Group uniquely assigned to user %(id)s',
logging_enabled = True,
register_log='User %(id)s Registered',
login_log='User %(id)s Logged-in',
login_failed_log=None,
@@ -1750,7 +1750,7 @@ class Auth(object):
user_id = None # user unknown
vars = vars or {}
# log messages should not be translated
if type(descrption).__name__ == 'lazyT':
if type(description).__name__ == 'lazyT':
description = description.m
self.table_event().insert(
description=str(description % vars),
@@ -2048,10 +2048,15 @@ class Auth(object):
if next is DEFAULT:
# important for security
next = self.settings.login_next
if self.next:
host = self.next.split('//',1)[-1].split('/')[0]
if host in self.settings.cas_domains:
next = self.next
user_next = self.next
if user_next:
external = user_next.split('://')
if external[0].lower() in ['http', 'https', 'ftp']:
host_next = user_next.split('//', 1)[-1].split('/')[0]
if host_next in self.settings.cas_domains:
next = user_next
else:
next = user_next
if onvalidation is DEFAULT:
onvalidation = self.settings.login_onvalidation
if onaccept is DEFAULT: