--- a/server/sources/native.py Thu May 19 10:36:26 2011 +0200
+++ b/server/sources/native.py Thu May 19 10:53:11 2011 +0200
@@ -304,9 +304,9 @@
self.dbhelper.dbname = abspath(self.dbhelper.dbname)
self.get_connection = lambda: ConnectionWrapper(self)
self.check_connection = lambda cnx: cnx
- def pool_reset(cnx):
+ def cnxset_freed(cnx):
cnx.close()
- self.pool_reset = pool_reset
+ self.cnxset_freed = cnxset_freed
if self.dbdriver == 'sqlite':
self._create_eid = None
self.create_eid = self._create_eid_sqlite
@@ -346,21 +346,21 @@
"""execute the query and return its result"""
return self.process_result(self.doexec(session, sql, args))
- def init_creating(self, pool=None):
+ def init_creating(self, cnxset=None):
# check full text index availibility
if self.do_fti:
- if pool is None:
- _pool = self.repo._get_pool()
- _pool.pool_set()
+ if cnxset is None:
+ _cnxset = self.repo._get_cnxset()
+ _cnxset.cnxset_set()
else:
- _pool = pool
- if not self.dbhelper.has_fti_table(_pool['system']):
+ _cnxset = cnxset
+ if not self.dbhelper.has_fti_table(_cnxset['system']):
if not self.repo.config.creating:
self.critical('no text index table')
self.do_fti = False
- if pool is None:
- _pool.pool_reset()
- self.repo._free_pool(_pool)
+ if cnxset is None:
+ _cnxset.cnxset_freed()
+ self.repo._free_cnxset(_cnxset)
def backup(self, backupfile, confirm, format='native'):
"""method called to create a backup of the source's data"""
@@ -368,25 +368,25 @@
self.repo.fill_schema()
self.set_schema(self.repo.schema)
helper = DatabaseIndependentBackupRestore(self)
- self.close_pool_connections()
+ self.close_source_connections()
try:
helper.backup(backupfile)
finally:
- self.open_pool_connections()
+ self.open_source_connections()
elif format == 'native':
- self.close_pool_connections()
+ self.close_source_connections()
try:
self.backup_to_file(backupfile, confirm)
finally:
- self.open_pool_connections()
+ self.open_source_connections()
else:
raise ValueError('Unknown format %r' % format)
def restore(self, backupfile, confirm, drop, format='native'):
"""method called to restore a backup of source's data"""
- if self.repo.config.open_connections_pools:
- self.close_pool_connections()
+ if self.repo.config.init_cnxset_pool:
+ self.close_source_connections()
try:
if format == 'portable':
helper = DatabaseIndependentBackupRestore(self)
@@ -396,12 +396,12 @@
else:
raise ValueError('Unknown format %r' % format)
finally:
- if self.repo.config.open_connections_pools:
- self.open_pool_connections()
+ if self.repo.config.init_cnxset_pool:
+ self.open_source_connections()
def init(self, activated, source_entity):
- self.init_creating(source_entity._cw.pool)
+ self.init_creating(source_entity._cw.cnxset)
def shutdown(self):
if self._eid_creation_cnx:
@@ -523,13 +523,13 @@
raise
# FIXME: better detection of deconnection pb
self.warning("trying to reconnect")
- session.pool.reconnect(self)
+ session.cnxset.reconnect(self)
cursor = self.doexec(session, sql, args)
except (self.DbapiError,), exc:
# We get this one with pyodbc and SQL Server when connection was reset
if exc.args[0] == '08S01' and session.mode != 'write':
self.warning("trying to reconnect")
- session.pool.reconnect(self)
+ session.cnxset.reconnect(self)
cursor = self.doexec(session, sql, args)
else:
raise
@@ -718,9 +718,9 @@
"""Execute a query.
it's a function just so that it shows up in profiling
"""
- cursor = session.pool[self.uri]
+ cursor = session.cnxset[self.uri]
if server.DEBUG & server.DBG_SQL:
- cnx = session.pool.connection(self.uri)
+ cnx = session.cnxset.connection(self.uri)
# getattr to get the actual connection if cnx is a ConnectionWrapper
# instance
print 'exec', query, args, getattr(cnx, '_cnx', cnx)
@@ -735,7 +735,7 @@
query, args, ex.args[0])
if rollback:
try:
- session.pool.connection(self.uri).rollback()
+ session.cnxset.connection(self.uri).rollback()
if self.repo.config.mode != 'test':
self.critical('transaction has been rollbacked')
except:
@@ -764,7 +764,7 @@
"""
if server.DEBUG & server.DBG_SQL:
print 'execmany', query, 'with', len(args), 'arguments'
- cursor = session.pool[self.uri]
+ cursor = session.cnxset[self.uri]
try:
# str(query) to avoid error if it's an unicode string
cursor.executemany(str(query), args)
@@ -775,7 +775,7 @@
self.critical("sql many: %r\n args: %s\ndbms message: %r",
query, args, ex.args[0])
try:
- session.pool.connection(self.uri).rollback()
+ session.cnxset.connection(self.uri).rollback()
if self.repo.config.mode != 'test':
self.critical('transaction has been rollbacked')
except:
@@ -793,7 +793,7 @@
self.error("backend can't alter %s.%s to %s%s", table, column, coltype,
not allownull and 'NOT NULL' or '')
return
- self.dbhelper.change_col_type(LogCursor(session.pool[self.uri]),
+ self.dbhelper.change_col_type(LogCursor(session.cnxset[self.uri]),
table, column, coltype, allownull)
self.info('altered %s.%s: now %s%s', table, column, coltype,
not allownull and 'NOT NULL' or '')
@@ -808,7 +808,7 @@
return
table, column = rdef_table_column(rdef)
coltype, allownull = rdef_physical_info(self.dbhelper, rdef)
- self.dbhelper.set_null_allowed(LogCursor(session.pool[self.uri]),
+ self.dbhelper.set_null_allowed(LogCursor(session.cnxset[self.uri]),
table, column, coltype, allownull)
def update_rdef_indexed(self, session, rdef):
@@ -826,11 +826,11 @@
self.drop_index(session, table, column, unique=True)
def create_index(self, session, table, column, unique=False):
- cursor = LogCursor(session.pool[self.uri])
+ cursor = LogCursor(session.cnxset[self.uri])
self.dbhelper.create_index(cursor, table, column, unique)
def drop_index(self, session, table, column, unique=False):
- cursor = LogCursor(session.pool[self.uri])
+ cursor = LogCursor(session.cnxset[self.uri])
self.dbhelper.drop_index(cursor, table, column, unique)
# system source interface #################################################
@@ -841,7 +841,7 @@
try:
res = self.doexec(session, sql).fetchone()
except:
- assert session.pool, 'session has no pool set'
+ assert session.cnxset, 'session has no connections set'
raise UnknownEid(eid)
if res is None:
raise UnknownEid(eid)
@@ -1135,7 +1135,7 @@
important note: while undoing of a transaction, only hooks in the
'integrity', 'activeintegrity' and 'undo' categories are called.
"""
- # set mode so pool isn't released subsquently until commit/rollback
+ # set mode so connections set isn't released subsquently until commit/rollback
session.mode = 'write'
errors = []
session.transaction_data['undoing_uuid'] = txuuid
@@ -1380,7 +1380,7 @@
def fti_unindex_entities(self, session, entities):
"""remove text content for entities from the full text index
"""
- cursor = session.pool['system']
+ cursor = session.cnxset['system']
cursor_unindex_object = self.dbhelper.cursor_unindex_object
try:
for entity in entities:
@@ -1393,7 +1393,7 @@
"""add text content of created/modified entities to the full text index
"""
cursor_index_object = self.dbhelper.cursor_index_object
- cursor = session.pool['system']
+ cursor = session.cnxset['system']
try:
# use cursor_index_object, not cursor_reindex_object since
# unindexing done in the FTIndexEntityOp