No more default capture of integrity error
This commit is contained in:
2
VERSION
2
VERSION
@@ -1 +1 @@
|
||||
Version 2.4.7-stable+timestamp.2013.05.31.21.33.54
|
||||
Version 2.4.7-stable+timestamp.2013.06.01.18.23.56
|
||||
|
||||
36
gluon/dal.py
36
gluon/dal.py
@@ -683,12 +683,6 @@ class BaseAdapter(ConnectionPool):
|
||||
return str(obj)
|
||||
return self.adapt(str(obj))
|
||||
|
||||
def integrity_error(self):
|
||||
return self.driver.IntegrityError
|
||||
|
||||
def operational_error(self):
|
||||
return self.driver.OperationalError
|
||||
|
||||
def file_exists(self, filename):
|
||||
"""
|
||||
to be used ONLY for files that on GAE may not be on filesystem
|
||||
@@ -738,7 +732,6 @@ class BaseAdapter(ConnectionPool):
|
||||
else:
|
||||
raise RuntimeError("no driver available %s" % str(self.drivers))
|
||||
|
||||
|
||||
def __init__(self, db,uri,pool_size=0, folder=None, db_codec='UTF-8',
|
||||
credential_decoder=IDENTITY, driver_args={},
|
||||
adapter_args={},do_connect=True, after_connection=None):
|
||||
@@ -1212,8 +1205,8 @@ class BaseAdapter(ConnectionPool):
|
||||
self.execute(query)
|
||||
except Exception:
|
||||
e = sys.exc_info()[1]
|
||||
if isinstance(e,self.integrity_error_class()):
|
||||
return None
|
||||
if hasattr(table,'_on_insert_error'):
|
||||
return table._on_insert_error(table,fields,e)
|
||||
raise e
|
||||
if hasattr(table,'_primarykey'):
|
||||
return dict([(k[0].name, k[1]) for k in fields \
|
||||
@@ -1449,7 +1442,14 @@ class BaseAdapter(ConnectionPool):
|
||||
|
||||
def update(self, tablename, query, fields):
|
||||
sql = self._update(tablename, query, fields)
|
||||
self.execute(sql)
|
||||
try:
|
||||
self.execute(sql)
|
||||
except Exception:
|
||||
e = sys.exc_info()[1]
|
||||
table = self.db[tablename]
|
||||
if hasattr(table,'_on_update_error'):
|
||||
return table._on_update_error(table,query,fields,e)
|
||||
raise e
|
||||
try:
|
||||
return self.cursor.rowcount
|
||||
except:
|
||||
@@ -1873,9 +1873,6 @@ class BaseAdapter(ConnectionPool):
|
||||
def lastrowid(self, table):
|
||||
return None
|
||||
|
||||
def integrity_error_class(self):
|
||||
return type(None)
|
||||
|
||||
def rowslice(self, rows, minimum=0, maximum=None):
|
||||
"""
|
||||
By default this function does nothing;
|
||||
@@ -3216,9 +3213,6 @@ class MSSQLAdapter(BaseAdapter):
|
||||
self.execute('SELECT SCOPE_IDENTITY();')
|
||||
return long(self.cursor.fetchone()[0])
|
||||
|
||||
def integrity_error_class(self):
|
||||
return pyodbc.IntegrityError
|
||||
|
||||
def rowslice(self,rows,minimum=0,maximum=None):
|
||||
if maximum is None:
|
||||
return rows[minimum:]
|
||||
@@ -3482,9 +3476,6 @@ class SybaseAdapter(MSSQLAdapter):
|
||||
self.connector = connector
|
||||
if do_connect: self.reconnect()
|
||||
|
||||
def integrity_error_class(self):
|
||||
return RuntimeError # FIX THIS
|
||||
|
||||
|
||||
class FireBirdAdapter(BaseAdapter):
|
||||
drivers = ('kinterbasdb','firebirdsql','fdb','pyodbc')
|
||||
@@ -3775,9 +3766,6 @@ class InformixAdapter(BaseAdapter):
|
||||
def lastrowid(self,table):
|
||||
return self.cursor.sqlerrd[1]
|
||||
|
||||
def integrity_error_class(self):
|
||||
return informixdb.IntegrityError
|
||||
|
||||
class InformixSEAdapter(InformixAdapter):
|
||||
""" work in progress """
|
||||
|
||||
@@ -4050,9 +4038,6 @@ class IngresAdapter(BaseAdapter):
|
||||
self.execute('select current value for %s' % tmp_seqname)
|
||||
return long(self.cursor.fetchone()[0]) # don't really need int type cast here...
|
||||
|
||||
def integrity_error_class(self):
|
||||
return self._driver.IntegrityError
|
||||
|
||||
|
||||
class IngresUnicodeAdapter(IngresAdapter):
|
||||
|
||||
@@ -4528,7 +4513,6 @@ class NoSQLAdapter(BaseAdapter):
|
||||
def execute(self,*a,**b): raise SyntaxError("Not supported")
|
||||
def represent_exceptions(self, obj, fieldtype): raise SyntaxError("Not supported")
|
||||
def lastrowid(self,table): raise SyntaxError("Not supported")
|
||||
def integrity_error_class(self): raise SyntaxError("Not supported")
|
||||
def rowslice(self,rows,minimum=0,maximum=None): raise SyntaxError("Not supported")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user