--- a/server/migractions.py Fri Aug 21 14:59:00 2009 +0200
+++ b/server/migractions.py Fri Aug 21 15:02:03 2009 +0200
@@ -152,14 +152,12 @@
def restore_database(self, backupfile, drop=True, systemonly=True,
askconfirm=True):
- config = self.config
- repo = self.repo_connect()
# check
if not osp.exists(backupfile):
raise Exception("Backup file %s doesn't exist" % backupfile)
return
if askconfirm and not self.confirm('Restore %s database from %s ?'
- % (config.appid, backupfile)):
+ % (self.config.appid, backupfile)):
return
# unpack backup
bkup = tarfile.open(backupfile, 'r|gz')
@@ -170,6 +168,9 @@
bkup = tarfile.open(backupfile, 'r|gz')
tmpdir = tempfile.mkdtemp()
bkup.extractall(path=tmpdir)
+
+ self.config.open_connections_pools = False
+ repo = self.repo_connect()
for source in repo.sources:
if systemonly and source.uri != 'system':
continue
@@ -182,6 +183,7 @@
bkup.close()
shutil.rmtree(tmpdir)
# call hooks
+ repo.open_connections_pools()
repo.hm.call_hooks('server_restore', repo=repo, timestamp=backupfile)
print '-> database restored.'
--- a/server/repository.py Fri Aug 21 14:59:00 2009 +0200
+++ b/server/repository.py Fri Aug 21 15:02:03 2009 +0200
@@ -176,6 +176,11 @@
# create the hooks manager
self.hm = HooksManager(self.schema)
# open some connections pools
+ if config.open_connections_pools:
+ self.open_connections_pools()
+
+ def open_connections_pools(self):
+ config = self.config
self._available_pools = Queue.Queue()
self._available_pools.put_nowait(ConnectionsPool(self.sources))
if config.read_instance_schema:
--- a/server/serverconfig.py Fri Aug 21 14:59:00 2009 +0200
+++ b/server/serverconfig.py Fri Aug 21 15:02:03 2009 +0200
@@ -178,6 +178,10 @@
}),
) + CubicWebConfiguration.options)
+ # should we open connections pools (eg connect to sources). This is usually
+ # necessary...
+ open_connections_pools = True
+
# read the schema from the database
read_instance_schema = True
bootstrap_schema = True
--- a/server/sources/native.py Fri Aug 21 14:59:00 2009 +0200
+++ b/server/sources/native.py Fri Aug 21 15:02:03 2009 +0200
@@ -216,11 +216,13 @@
def restore(self, backupfile, drop):
"""method called to restore a backup of source's data"""
- self.close_pool_connections()
+ if self.repo.config.open_connections_pools:
+ self.close_pool_connections()
try:
self.restore_from_file(backupfile, drop)
finally:
- self.open_pool_connections()
+ if self.repo.config.open_connections_pools:
+ self.open_pool_connections()
def init(self):
self.init_creating()