--- a/server/migractions.py Tue Jun 23 13:31:35 2009 +0200
+++ b/server/migractions.py Tue Jun 23 13:36:38 2009 +0200
@@ -23,7 +23,7 @@
from datetime import datetime
from logilab.common.deprecation import deprecated_function, obsolete
-from logilab.common.decorators import cached
+from logilab.common.decorators import cached, clear_cache
from logilab.common.adbh import get_adv_func_helper
from yams.constraints import SizeConstraint
@@ -35,8 +35,8 @@
from cubicweb.common.migration import MigrationHelper, yes
try:
- from cubicweb.server import schemaserial as ss
- from cubicweb.server.utils import manager_userpasswd
+ from cubicweb.server import SOURCE_TYPES, schemaserial as ss
+ from cubicweb.server.utils import manager_userpasswd, ask_source_config
from cubicweb.server.sqlutils import sqlexec, SQL_PREFIX
except ImportError: # LAX
pass
@@ -77,7 +77,8 @@
"""write current installed versions (of cubicweb software
and of each used cube) into the database
"""
- self.cmd_set_property('system.version.cubicweb', self.config.cubicweb_version())
+ self.cmd_set_property('system.version.cubicweb',
+ self.config.cubicweb_version())
for pkg in self.config.cubes():
pkgversion = self.config.cube_version(pkg)
self.cmd_set_property('system.version.%s' % pkg.lower(), pkgversion)
@@ -479,9 +480,16 @@
newcubes = super(ServerMigrationHelper, self).cmd_add_cubes(cubes)
if not newcubes:
return
- for pack in newcubes:
- self.cmd_set_property('system.version.'+pack,
- self.config.cube_version(pack))
+ for cube in newcubes:
+ self.cmd_set_property('system.version.'+cube,
+ self.config.cube_version(cube))
+ if cube in SOURCE_TYPES:
+ # don't use config.sources() in case some sources have been
+ # disabled for migration
+ sourcescfg = self.config.read_sources_file()
+ sourcescfg[cube] = ask_source_config(cube)
+ self.config.write_sources_file(sourcescfg)
+ clear_cache(self.config, 'read_sources_file')
if not update_database:
self.commit()
return
@@ -515,8 +523,9 @@
self.exec_event_script('postcreate', self.config.cube_dir(pack))
self.commit()
- def cmd_remove_cube(self, cube):
- removedcubes = super(ServerMigrationHelper, self).cmd_remove_cube(cube)
+ def cmd_remove_cube(self, cube, removedeps=False):
+ removedcubes = super(ServerMigrationHelper, self).cmd_remove_cube(
+ cube, removedeps)
if not removedcubes:
return
fsschema = self.fs_schema
@@ -688,7 +697,8 @@
`newname` is a string giving the name of the renamed entity type
"""
self.rqlexec('SET ET name %(newname)s WHERE ET is CWEType, ET name %(oldname)s',
- {'newname' : unicode(newname), 'oldname' : oldname})
+ {'newname' : unicode(newname), 'oldname' : oldname},
+ ask_confirm=False)
if commit:
self.commit()