--- a/server/serverconfig.py Mon Nov 23 14:13:53 2009 +0100
+++ b/server/serverconfig.py Thu Dec 03 17:17:43 2009 +0100
@@ -10,7 +10,7 @@
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
@@ -28,12 +28,22 @@
'inputlevel': 0,
}),
('password', {'type' : 'password',
+ 'default': REQUIRED,
'help': "cubicweb manager account's password",
'inputlevel': 0,
}),
)
-def generate_sources_file(sourcesfile, sourcescfg, keys=None):
+class SourceConfiguration(Configuration):
+ def __init__(self, appid, options):
+ self.appid = appid # has to be done before super call
+ super(SourceConfiguration, self).__init__(options=options)
+
+ # 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
@@ -53,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
@@ -236,7 +246,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):