--- a/server/pool.py Sat Oct 09 00:05:50 2010 +0200
+++ b/server/pool.py Sat Oct 09 00:05:52 2010 +0200
@@ -34,7 +34,7 @@
# dictionnary of (source, connection), indexed by sources'uri
self.source_cnxs = {}
for source in sources:
- self.source_cnxs[source.uri] = (source, source.get_connection())
+ self.add_source(source)
if not 'system' in self.source_cnxs:
self.source_cnxs['system'] = self.source_cnxs[sources[0].uri]
self._cursors = {}
@@ -50,6 +50,15 @@
self._cursors[uri] = cursor
return cursor
+ def add_source(self, source):
+ assert not source.uri in self.source_cnxs
+ self.source_cnxs[source.uri] = (source, source.get_connection())
+
+ def remove_source(self, source):
+ source, cnx = self.source_cnxs.pop(source.uri)
+ cnx.close()
+ self._cursors.pop(source.uri, None)
+
def commit(self):
"""commit the current transaction for this user"""
# FIXME: what happends if a commit fail