# HG changeset patch # User Adrien Di Mascio # Date 1259001236 -3600 # Node ID 4e619e97b3fd70769a0f454963193c10cb87f9d4 # Parent 07fa1a2f1a569fe91ee985549f149df8dad6f676# Parent 8117ffd92e6a33848b5dfac76e3eff7cc4d0904d merge diff -r 07fa1a2f1a56 -r 4e619e97b3fd devtools/migrtest.py --- a/devtools/migrtest.py Mon Nov 23 19:30:00 2009 +0100 +++ b/devtools/migrtest.py Mon Nov 23 19:33:56 2009 +0100 @@ -74,7 +74,7 @@ sources['system']['db-host'] = None sources['system']['db-user'] = tmpdbuser sources['system']['db-password'] = None - generate_sources_file(join(testapplhome, 'sources'), sources) + generate_sources_file(applid, join(testapplhome, 'sources'), sources) ## # create postgres password file so we won't need anymore passwords ## # XXX may exist! ## pgpassfile = expanduser('~/.pgpass') diff -r 07fa1a2f1a56 -r 4e619e97b3fd server/serverconfig.py --- a/server/serverconfig.py Mon Nov 23 19:30:00 2009 +0100 +++ b/server/serverconfig.py Mon Nov 23 19:33:56 2009 +0100 @@ -34,7 +34,16 @@ }), ) -def generate_sources_file(sourcesfile, sourcescfg, keys=None): +class SourceConfiguration(Configuration): + def __init__(self, appid, options): + super(SourceConfiguration, self).__init__(options=options) + self.appid = appid + + # make Method('default_instance_id') usable in db option defs (in native.py) + def default_instance_id(self): + return self.appid + +def generate_sources_file(appid, sourcesfile, sourcescfg, keys=None): """serialize repository'sources configuration into a INI like file the `keys` parameter may be used to sort sections @@ -54,7 +63,7 @@ options = USER_OPTIONS else: options = SOURCE_TYPES[sconfig['adapter']].options - _sconfig = Configuration(options=options) + _sconfig = SourceConfiguration(appid, options=options) for attr, val in sconfig.items(): if attr == 'uri': continue @@ -242,7 +251,8 @@ if exists(sourcesfile): import shutil shutil.copy(sourcesfile, sourcesfile + '.bak') - generate_sources_file(sourcesfile, sourcescfg, ['admin', 'system']) + generate_sources_file(self.appid, sourcesfile, sourcescfg, + ['admin', 'system']) restrict_perms_to_user(sourcesfile) def pyro_enabled(self): diff -r 07fa1a2f1a56 -r 4e619e97b3fd server/serverctl.py --- a/server/serverctl.py Mon Nov 23 19:30:00 2009 +0100 +++ b/server/serverctl.py Mon Nov 23 19:33:56 2009 +0100 @@ -14,11 +14,13 @@ from logilab.common.clcommands import register_commands, cmd_run, pop_arg from logilab.common.shellutils import ASK -from cubicweb import AuthenticationError, ExecutionError, ConfigurationError, underline_title +from cubicweb import (AuthenticationError, ExecutionError, ConfigurationError, + underline_title) from cubicweb.toolsutils import Command, CommandHandler from cubicweb.server import SOURCE_TYPES from cubicweb.server.utils import ask_source_config -from cubicweb.server.serverconfig import USER_OPTIONS, ServerConfiguration +from cubicweb.server.serverconfig import (USER_OPTIONS, ServerConfiguration, + SourceConfiguration) # utility functions ########################################################### @@ -113,6 +115,7 @@ config._cubes = None login, pwd = manager_userpasswd() + # repository specific command handlers ######################################## class RepositoryCreateHandler(CommandHandler): @@ -135,8 +138,8 @@ sourcesfile = config.sources_file() # XXX hack to make Method('default_instance_id') usable in db option # defs (in native.py) - Configuration.default_instance_id = staticmethod(lambda: config.appid) - sconfig = Configuration(options=SOURCE_TYPES['native'].options) + sconfig = SourceConfiguration(config.appid, + options=SOURCE_TYPES['native'].options) sconfig.adapter = 'native' sconfig.input_config(inputlevel=inputlevel) sourcescfg = {'system': sconfig}