fix unit tests by not using the new create_eid implementation with sqlite stable
authorAlexandre Fayolle <alexandre.fayolle@logilab.fr>
Thu, 03 Jun 2010 09:41:41 +0200
branchstable
changeset 5649 a07dee204187
parent 5648 d6bee21cf5db
child 5650 86e874fe30ea
child 5659 755f56f01c9d
fix unit tests by not using the new create_eid implementation with sqlite Actually, fix a couple of issues with a previous attempt: * do not use double underscores as method patching will fail with these * old method must always be used with sqlite regardless of the no_sqlite_wrap attribute
server/sources/native.py
--- a/server/sources/native.py	Thu Jun 03 09:24:41 2010 +0200
+++ b/server/sources/native.py	Thu Jun 03 09:41:41 2010 +0200
@@ -272,7 +272,9 @@
             def pool_reset(cnx):
                 cnx.close()
             self.pool_reset = pool_reset
-            self.create_eid = self.__create_eid_sqlite
+        if self.dbdriver == 'sqlite':
+            self._create_eid = None
+            self.create_eid = self._create_eid_sqlite
 
     @property
     def _sqlcnx(self):
@@ -713,7 +715,7 @@
         return None
 
     def make_temp_table_name(self, table):
-        try: # XXX remove this once 
+        try: # XXX remove this once
             return self.dbhelper.temporary_table_name(table)
         except AttributeError:
             import warnings
@@ -731,7 +733,7 @@
         sql = self.dbhelper.sql_temporary_table(table, schema, False)
         self.doexec(session, sql)
 
-    def __create_eid_sqlite(self, session):
+    def _create_eid_sqlite(self, session):
         self._eid_creation_lock.acquire()
         try:
             for sql in self.dbhelper.sqls_increment_sequence('entities_id_seq'):
@@ -744,15 +746,15 @@
     def create_eid(self, session):
         self.debug('create eid')
         # lock needed to prevent 'Connection is busy with results for another command (0)' errors with SQLServer
-        self._eid_creation_lock.acquire() 
+        self._eid_creation_lock.acquire()
         try:
-            return self.__create_eid()
+            return self._create_eid()
         finally:
             self._eid_creation_lock.release()
-            
-    def __create_eid(self):
-        # internal function doing the eid creation without locking. 
-        # needed for the recursive handling of disconnections (otherwise we 
+
+    def _create_eid(self):
+        # internal function doing the eid creation without locking.
+        # needed for the recursive handling of disconnections (otherwise we
         # deadlock on self._eid_creation_lock
         if self._eid_creation_cnx is None:
             self._eid_creation_cnx = self.get_connection()
@@ -766,13 +768,13 @@
             # FIXME: better detection of deconnection pb
             self.warning("trying to reconnect create eid connection")
             self._eid_creation_cnx = None
-            return self.__create_eid()
+            return self._create_eid()
         except (self.DbapiError,), exc:
             # We get this one with pyodbc and SQL Server when connection was reset
             if exc.args[0] == '08S01':
                 self.warning("trying to reconnect create eid connection")
                 self._eid_creation_cnx = None
-                return self.__create_eid()
+                return self._create_eid()
             else:
                 raise
         except: # WTF?
@@ -783,7 +785,7 @@
         else:
             cnx.commit()
             return eid
-            
+
 
     def add_info(self, session, entity, source, extid, complete):
         """add type and source info for an eid into the system table"""