bug detection for Storage, reverted improvements in dal :-(

This commit is contained in:
mdipierro
2012-08-22 10:48:17 -05:00
parent 180ae1027f
commit b7623af28c
3 changed files with 129 additions and 74 deletions
+23 -9
View File
@@ -6281,9 +6281,16 @@ class Row(dict):
this is only used to store a Row
"""
def __init__(self,*args,**kwargs):
dict.__init__(self,*args,**kwargs)
self.__dict__ = self
# IF NOT HAVE BUG http://bugs.python.org/issue1469629 uncommend these lines and comment __getattr__, __setattr__
# def __init__(self,*args,**kwargs):
# dict.__init__(self,*args,**kwargs)
# self.__dict__ = self
def __getattr__(self, key):
return self[key]
def __setattr__(self, key, value):
self[key] = value
def __getitem__(self, key):
key=str(key)
@@ -6572,7 +6579,7 @@ class DAL(dict):
:fake_migrate_all (defaults to False). If sets to True fake migrates ALL tables
:attempts (defaults to 5). Number of times to attempt connecting
"""
self.__dict__ = self
# self.__dict__ = self # http://bugs.python.org/issue1469629
if not decode_credentials:
credential_decoder = lambda cred: cred
else:
@@ -6983,8 +6990,7 @@ def index():
yield self[tablename]
def __getitem__(self, key):
key = str(key)
return dict.__getitem__(self,key)
return self.__getattr__(str(key))
def __getattr__(self, key):
if not key is '_LAZY_TABLES' and key in self._LAZY_TABLES:
@@ -6999,7 +7005,9 @@ def index():
if key[:1]!='_' and key in self:
raise SyntaxError, \
'Object %s exists and cannot be redefined' % key
dict.__setattr__(self,key,value)
dict.__setitem__(self,key,value)
# replace above line with below if not have bug http://bugs.python.org/issue1469629
# dict.__setattr__(self,key,value)
def __repr__(self):
return '<DAL ' + dict.__repr__(self) + '>'
@@ -7201,7 +7209,7 @@ class Table(dict):
:raises SyntaxError: when a supplied field is of incorrect type.
"""
self.__dict__ = self
# self.__dict__ = self # http://bugs.python.org/issue1469629
self._actual = False # set to True by define_table()
self._tablename = tablename
self._sequence_name = args.get('sequence_name',None) or \
@@ -7463,6 +7471,10 @@ class Table(dict):
'value must be a dictionary: %s' % value
dict.__setitem__(self, str(key), value)
# comment if not have bug http://bugs.python.org/issue1469629
def __getattr__(self, key):
return self[key]
def __delitem__(self, key):
if isinstance(key, dict):
query = self._build_query(key)
@@ -7474,7 +7486,9 @@ class Table(dict):
def __setattr__(self, key, value):
if key[:1]!='_' and key in self:
raise SyntaxError, 'Object exists and cannot be redefined: %s' % key
dict.__setattr__(self,key,value)
self[key] = value
# replace with line below if have bug http://bugs.python.org/issue1469629
# dict.__setattr__(self,key,value)
def __iter__(self):
for fieldname in self.fields: