resynced recent patches, sorry for the mess

This commit is contained in:
mdipierro
2013-06-20 16:44:16 -05:00
parent e055c3af7e
commit 08f813d670
5 changed files with 27 additions and 22 deletions
+1 -1
View File
@@ -1 +1 @@
Version 2.5.1-stable+timestamp.2013.06.18.07.44.05 Version 2.5.1-stable+timestamp.2013.06.20.16.43.32
@@ -9,7 +9,7 @@
thanks and credits to the web2py community thanks and credits to the web2py community
This custom authenticator allows web2py to authenticate using browserid (https://browserid.org/) This custom authenticator allows web2py to authenticate using browserid (https://login.persona.org/)
BrowserID is a project by Mozilla Labs (http://mozillalabs.com/) BrowserID is a project by Mozilla Labs (http://mozillalabs.com/)
to Know how browserid works please visit http://identity.mozilla.com/post/7616727542/introducing-browserid-a-better-way-to-sign-in to Know how browserid works please visit http://identity.mozilla.com/post/7616727542/introducing-browserid-a-better-way-to-sign-in
@@ -39,10 +39,10 @@ class BrowserID(object):
audience="", audience="",
assertion_post_url="", assertion_post_url="",
prompt="BrowserID Login", prompt="BrowserID Login",
issuer="browserid.org", issuer="login.persona.org",
verify_url="https://browserid.org/verify", verify_url="https://login.persona.org/verify",
browserid_js="https://browserid.org/include.js", browserid_js="https://login.persona.org/include.js",
browserid_button="https://browserid.org/i/sign_in_red.png", browserid_button="https://login.persona.org/i/sign_in_red.png",
crypto_js="https://crypto-js.googlecode.com/files/2.2.0-crypto-md5.js", crypto_js="https://crypto-js.googlecode.com/files/2.2.0-crypto-md5.js",
on_login_failure=None, on_login_failure=None,
): ):
@@ -76,9 +76,13 @@ class BrowserID(object):
if j["status"] == "okay" and j["audience"] == audience and j['issuer'] == issuer and j['expires'] >= epoch_time: if j["status"] == "okay" and j["audience"] == audience and j['issuer'] == issuer and j['expires'] >= epoch_time:
return dict(email=j['email']) return dict(email=j['email'])
elif self.on_login_failure: elif self.on_login_failure:
redirect('http://google.com') #print "status: ", j["status"]=="okay", j["status"]
#print "audience:", j["audience"]==audience, j["audience"], audience
#print "issuer: ", j["issuer"]==issuer, j["issuer"], issuer
#print "expires: ", j["expires"] >= epoch_time, j["expires"], epoch_time
redirect(self.on_login_failure)
else: else:
redirect('http://google.com') redirect('https://login.persona.org')
return None return None
def login_form(self): def login_form(self):
+11 -11
View File
@@ -476,7 +476,7 @@ def quote_keyword(a,keyword='timestamp'):
regex = re.compile('\.keyword(?=\w)') regex = re.compile('\.keyword(?=\w)')
a = regex.sub('."%s"' % keyword,a) a = regex.sub('."%s"' % keyword,a)
return a return a
if 'google' in DRIVERS: if 'google' in DRIVERS:
is_jdbc = False is_jdbc = False
@@ -1188,7 +1188,7 @@ class BaseAdapter(ConnectionPool):
self.file_delete(table._dbt) self.file_delete(table._dbt)
logfile.write('success!\n') logfile.write('success!\n')
def _insert(self, table, fields): def _insert(self, table, fields):
if fields: if fields:
keys = ','.join(f.name for f, v in fields) keys = ','.join(f.name for f, v in fields)
values = ','.join(self.expand(v, f.type) for f, v in fields) values = ','.join(self.expand(v, f.type) for f, v in fields)
@@ -1309,7 +1309,7 @@ class BaseAdapter(ConnectionPool):
return ftype in ('integer','boolean','double','bigint') or \ return ftype in ('integer','boolean','double','bigint') or \
ftype.startswith('decimal') ftype.startswith('decimal')
def REPLACE(self, first, (second, third)): def REPLACE(self, first, (second, third)):
return 'REPLACE(%s,%s,%s)' % (self.expand(first,'string'), return 'REPLACE(%s,%s,%s)' % (self.expand(first,'string'),
self.expand(second,'string'), self.expand(second,'string'),
self.expand(third,'string')) self.expand(third,'string'))
@@ -1614,7 +1614,7 @@ class BaseAdapter(ConnectionPool):
sql_t = ', '.join([self.table_alias(t) for t in excluded + \ sql_t = ', '.join([self.table_alias(t) for t in excluded + \
tables_to_merge.keys()]) tables_to_merge.keys()])
if joint: if joint:
sql_t += ' %s %s' % (command, sql_t += ' %s %s' % (command,
','.join([self.table_alias(t) for t in joint])) ','.join([self.table_alias(t) for t in joint]))
for t in joinon: for t in joinon:
sql_t += ' %s %s' % (command, t) sql_t += ' %s %s' % (command, t)
@@ -1629,7 +1629,7 @@ class BaseAdapter(ConnectionPool):
for t in ijoinon: for t in ijoinon:
sql_t += ' %s %s' % (icommand, t) sql_t += ' %s %s' % (icommand, t)
if joint: if joint:
sql_t += ' %s %s' % (command, sql_t += ' %s %s' % (command,
','.join([self.table_alias(t) for t in joint])) ','.join([self.table_alias(t) for t in joint]))
for t in joinon: for t in joinon:
sql_t += ' %s %s' % (command, t) sql_t += ' %s %s' % (command, t)
@@ -1807,7 +1807,7 @@ class BaseAdapter(ConnectionPool):
if field_is_type('list:string'): if field_is_type('list:string'):
obj = map(str,obj) obj = map(str,obj)
else: else:
obj = map(int,obj) obj = map(int,[o for o in obj if o != ''])
# we don't want to bar_encode json objects # we don't want to bar_encode json objects
if isinstance(obj, (list, tuple)) and (not fieldtype == "json"): if isinstance(obj, (list, tuple)) and (not fieldtype == "json"):
obj = bar_encode(obj) obj = bar_encode(obj)
@@ -3047,7 +3047,7 @@ class OracleAdapter(BaseAdapter):
END IF; END IF;
SELECT %(sequence_name)s.nextval INTO :NEW.%(id)s FROM DUAL; SELECT %(sequence_name)s.nextval INTO :NEW.%(id)s FROM DUAL;
END; END;
""" % dict(trigger_name=trigger_name, tablename=tablename, """ % dict(trigger_name=trigger_name, tablename=tablename,
sequence_name=sequence_name,id=id_name)) sequence_name=sequence_name,id=id_name))
def lastrowid(self,table): def lastrowid(self,table):
@@ -8021,7 +8021,7 @@ def index():
ofile.write('END') ofile.write('END')
def import_from_csv_file(self, ifile, id_map=None, null='<NULL>', def import_from_csv_file(self, ifile, id_map=None, null='<NULL>',
unique='uuid', map_tablenames=None, unique='uuid', map_tablenames=None,
ignore_missing_tables=False, ignore_missing_tables=False,
*args, **kwargs): *args, **kwargs):
#if id_map is None: id_map={} #if id_map is None: id_map={}
@@ -8041,7 +8041,7 @@ def index():
tablename = map_tablenames.get(tablename,tablename) tablename = map_tablenames.get(tablename,tablename)
if tablename is not None and tablename in self.tables: if tablename is not None and tablename in self.tables:
self[tablename].import_from_csv_file( self[tablename].import_from_csv_file(
ifile, id_map, null, unique, id_offset, ifile, id_map, null, unique, id_offset,
*args, **kwargs) *args, **kwargs)
elif tablename is None or ignore_missing_tables: elif tablename is None or ignore_missing_tables:
# skip all non-empty lines # skip all non-empty lines
@@ -8484,7 +8484,7 @@ class Table(object):
def __repr__(self): def __repr__(self):
return '<Table %s (%s)>' % (self._tablename,','.join(self.fields())) return '<Table %s (%s)>' % (self._tablename,','.join(self.fields()))
def __str__(self): def __str__(self):
if self._ot is not None: if self._ot is not None:
if 'Oracle' in str(type(self._db._adapter)): # <<< patch if 'Oracle' in str(type(self._db._adapter)): # <<< patch
return '%s %s' % (self._ot, self._tablename) # <<< patch return '%s %s' % (self._ot, self._tablename) # <<< patch
@@ -10194,7 +10194,7 @@ class Rows(object):
return len(self.records) return len(self.records)
def __getslice__(self, a, b): def __getslice__(self, a, b):
return Rows(self.db,self.records[a:b],self.colnames) return Rows(self.db,self.records[a:b],self.colnames,compact=self.compact)
def __getitem__(self, i): def __getitem__(self, i):
row = self.records[i] row = self.records[i]
+1 -1
View File
@@ -499,7 +499,7 @@ class Session(Storage):
masterapp=None, masterapp=None,
clear_session=False clear_session=False
): ):
if request is None: if request is None:
request = current.request request = current.request
if response is None: if response is None:
+3 -2
View File
@@ -969,6 +969,7 @@ class Auth(object):
new_password='New password', new_password='New password',
old_password='Old password', old_password='Old password',
group_description='Group uniquely assigned to user %(id)s', group_description='Group uniquely assigned to user %(id)s',
logging_enabled = True,
register_log='User %(id)s Registered', register_log='User %(id)s Registered',
login_log='User %(id)s Logged-in', login_log='User %(id)s Logged-in',
login_failed_log=None, login_failed_log=None,
@@ -1739,7 +1740,7 @@ class Auth(object):
auth.log_event(description='this happened', origin='auth') auth.log_event(description='this happened', origin='auth')
""" """
if not description: if not self.settings.logging_enabled or not description:
return return
elif self.is_logged_in(): elif self.is_logged_in():
user_id = self.user.id user_id = self.user.id
@@ -1845,7 +1846,7 @@ class Auth(object):
""" """
from gluon.settings import global_settings from gluon.settings import global_settings
if global_settings.web2py_runtime_gae: if global_settings.web2py_runtime_gae:
user = Row(self.db.auth_user._filter_fields(user, id=True)) user = Row(self.settings.table_user._filter_fields(user, id=True))
delattr(user,'password') delattr(user,'password')
else: else:
user = Row(user) user = Row(user)