fixed some bugs with singleton and remobed password from session.auth.user
This commit is contained in:
@@ -1 +1 @@
|
|||||||
Version 2.0.9 (2012-09-30 00:23:07) dev
|
Version 2.0.9 (2012-09-30 07:26:14) dev
|
||||||
|
|||||||
+4
-4
@@ -6577,16 +6577,15 @@ class DAL(object):
|
|||||||
if 'singleton_code' in kwargs:
|
if 'singleton_code' in kwargs:
|
||||||
singleton_code = kwargs['singleton_code']
|
singleton_code = kwargs['singleton_code']
|
||||||
del kwargs['singleton_code']
|
del kwargs['singleton_code']
|
||||||
else:
|
singleton_code = hashlib.md5(uri).hexdigest()
|
||||||
singleton_code = hashlib.md5(uri).hexdigest()
|
|
||||||
try:
|
try:
|
||||||
db = thread_local.db_instances[singleton_code]
|
db = thread_local.db_instances[singleton_code]
|
||||||
if args or kwargs:
|
if args or kwargs:
|
||||||
raise RuntimeError, 'Cannot duplicate a Singleton'
|
raise RuntimeError, 'Cannot duplicate a Singleton'
|
||||||
except KeyError:
|
except KeyError:
|
||||||
db = super(DAL, cls).__new__(cls, uri, *args, **kwargs)
|
db = super(DAL, cls).__new__(cls, uri, *args, **kwargs)
|
||||||
db._singleton_code = singleton_code
|
|
||||||
thread_local.db_instances[singleton_code] = db
|
thread_local.db_instances[singleton_code] = db
|
||||||
|
db._singleton_code = singleton_code
|
||||||
return db
|
return db
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -6641,7 +6640,8 @@ class DAL(object):
|
|||||||
migrate_enabled=True, fake_migrate_all=False,
|
migrate_enabled=True, fake_migrate_all=False,
|
||||||
decode_credentials=False, driver_args=None,
|
decode_credentials=False, driver_args=None,
|
||||||
adapter_args=None, attempts=5, auto_import=False,
|
adapter_args=None, attempts=5, auto_import=False,
|
||||||
bigint_id=False,debug=False,lazy_tables=False):
|
bigint_id=False,debug=False,lazy_tables=False,
|
||||||
|
singleton_code=None):
|
||||||
"""
|
"""
|
||||||
Creates a new Database Abstraction Layer instance.
|
Creates a new Database Abstraction Layer instance.
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -419,11 +419,11 @@ class Response(Storage):
|
|||||||
BUTTON = TAG.button
|
BUTTON = TAG.button
|
||||||
admin = URL("admin","default","design",
|
admin = URL("admin","default","design",
|
||||||
args=current.request.application)
|
args=current.request.application)
|
||||||
from gluon.dal import thread
|
from gluon.dal import thread_local
|
||||||
if hasattr(thread,'instances'):
|
if hasattr(thread_local,'instances'):
|
||||||
dbstats = [TABLE(*[TR(PRE(row[0]),'%.2fms' % (row[1]*1000)) \
|
dbstats = [TABLE(*[TR(PRE(row[0]),'%.2fms' % (row[1]*1000)) \
|
||||||
for row in i.db._timings]) \
|
for row in i.db._timings]) \
|
||||||
for i in thread.instances]
|
for i in thread_local.instances]
|
||||||
dbtables = dict([(regex_nopasswd.sub('******',i.uri),
|
dbtables = dict([(regex_nopasswd.sub('******',i.uri),
|
||||||
{'defined':
|
{'defined':
|
||||||
sorted(list(set(i.db.tables) -
|
sorted(list(set(i.db.tables) -
|
||||||
@@ -431,7 +431,7 @@ class Response(Storage):
|
|||||||
'[no defined tables]',
|
'[no defined tables]',
|
||||||
'lazy': sorted(i.db._LAZY_TABLES.keys()) or
|
'lazy': sorted(i.db._LAZY_TABLES.keys()) or
|
||||||
'[no lazy tables]'})
|
'[no lazy tables]'})
|
||||||
for i in thread.instances])
|
for i in thread_local.instances])
|
||||||
else:
|
else:
|
||||||
dbstats = [] # if no db or on GAE
|
dbstats = [] # if no db or on GAE
|
||||||
dbtables = {}
|
dbtables = {}
|
||||||
|
|||||||
@@ -1710,6 +1710,7 @@ class Auth(object):
|
|||||||
login the user = db.auth_user(id)
|
login the user = db.auth_user(id)
|
||||||
"""
|
"""
|
||||||
user = Storage(self.table_user()._filter_fields(user,id=True))
|
user = Storage(self.table_user()._filter_fields(user,id=True))
|
||||||
|
if 'password' in user: del user.password
|
||||||
current.session.auth = Storage(
|
current.session.auth = Storage(
|
||||||
user = user,
|
user = user,
|
||||||
last_visit = current.request.now,
|
last_visit = current.request.now,
|
||||||
|
|||||||
Reference in New Issue
Block a user