default_instance id should also be available when silently rebuilding soures file
--- a/devtools/migrtest.py Mon Nov 23 18:13:20 2009 +0100
+++ b/devtools/migrtest.py Mon Nov 23 19:01:17 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')
--- a/server/serverconfig.py Mon Nov 23 18:13:20 2009 +0100
+++ b/server/serverconfig.py Mon Nov 23 19:01:17 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
+ 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):
--- a/server/serverctl.py Mon Nov 23 18:13:20 2009 +0100
+++ b/server/serverctl.py Mon Nov 23 19:01:17 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}