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