--- a/server/migractions.py Mon Jun 15 12:42:16 2009 +0200
+++ b/server/migractions.py Mon Jun 15 12:42:48 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
@@ -688,7 +696,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()
--- a/server/serverconfig.py Mon Jun 15 12:42:16 2009 +0200
+++ b/server/serverconfig.py Mon Jun 15 12:42:48 2009 +0200
@@ -10,15 +10,29 @@
import os
from os.path import join, exists
-from logilab.common.configuration import Method, Configuration, \
+from logilab.common.configuration import REQUIRED, Method, Configuration, \
ini_format_section
from logilab.common.decorators import wproperty, cached, clear_cache
from cubicweb import CW_SOFTWARE_ROOT, RegistryNotFound
from cubicweb.toolsutils import env_path, read_config, restrict_perms_to_user
from cubicweb.cwconfig import CubicWebConfiguration, merge_options
+from cubicweb.server import SOURCE_TYPES
+USER_OPTIONS = (
+ ('login', {'type' : 'string',
+ 'default': REQUIRED,
+ 'help': "cubicweb manager account's login "
+ '(this user will be created)',
+ 'inputlevel': 0,
+ }),
+ ('password', {'type' : 'password',
+ 'help': "cubicweb manager account's password",
+ 'inputlevel': 0,
+ }),
+ )
+
def generate_sources_file(sourcesfile, sourcescfg, keys=None):
"""serialize repository'sources configuration into a INI like file
@@ -35,7 +49,11 @@
sconfig = sourcescfg[uri]
if isinstance(sconfig, dict):
# get a Configuration object
- _sconfig = Configuration(options=SOURCE_TYPES[sconfig['adapter']].options)
+ if uri == 'admin':
+ options = USER_OPTIONS
+ else:
+ options = SOURCE_TYPES[sconfig['adapter']].options
+ _sconfig = Configuration(options=options)
for attr, val in sconfig.items():
if attr == 'uri':
continue
@@ -239,6 +257,9 @@
def write_sources_file(self, sourcescfg):
sourcesfile = self.sources_file()
+ if exists(sourcesfile):
+ import shutil
+ shutil.copy(sourcesfile, sourcesfile + '.bak')
generate_sources_file(sourcesfile, sourcescfg, ['admin', 'system'])
restrict_perms_to_user(sourcesfile)
--- a/server/serverctl.py Mon Jun 15 12:42:16 2009 +0200
+++ b/server/serverctl.py Mon Jun 15 12:42:48 2009 +0200
@@ -10,14 +10,14 @@
import sys
import os
-from logilab.common.configuration import REQUIRED, Configuration
+from logilab.common.configuration import Configuration
from logilab.common.clcommands import register_commands, cmd_run, pop_arg
from cubicweb import AuthenticationError, ExecutionError, ConfigurationError
from cubicweb.toolsutils import Command, CommandHandler, confirm
from cubicweb.server import SOURCE_TYPES
from cubicweb.server.utils import ask_source_config
-from cubicweb.server.serverconfig import ServerConfiguration
+from cubicweb.server.serverconfig import USER_OPTIONS, ServerConfiguration
# utility functions ###########################################################
@@ -176,19 +176,6 @@
else:
print 'nevermind, you can do it later using the db-create command'
-USER_OPTIONS = (
- ('login', {'type' : 'string',
- 'default': REQUIRED,
- 'help': "cubicweb manager account's login "
- '(this user will be created)',
- 'inputlevel': 0,
- }),
- ('password', {'type' : 'password',
- 'help': "cubicweb manager account's password",
- 'inputlevel': 0,
- }),
- )
-
class RepositoryDeleteHandler(CommandHandler):
cmdname = 'delete'