25 |
25 |
26 import logilab.common.configuration as lgconfig |
26 import logilab.common.configuration as lgconfig |
27 from logilab.common.decorators import wproperty, cached |
27 from logilab.common.decorators import wproperty, cached |
28 |
28 |
29 from cubicweb.toolsutils import read_config, restrict_perms_to_user |
29 from cubicweb.toolsutils import read_config, restrict_perms_to_user |
30 from cubicweb.cwconfig import CONFIGURATIONS, CubicWebConfiguration, merge_options |
30 from cubicweb.cwconfig import CONFIGURATIONS, CubicWebConfiguration |
31 from cubicweb.server import SOURCE_TYPES |
31 from cubicweb.server import SOURCE_TYPES |
32 |
32 |
33 |
33 |
34 USER_OPTIONS = ( |
34 USER_OPTIONS = ( |
35 ('login', {'type' : 'string', |
35 ('login', {'type' : 'string', |
94 name = 'repository' |
94 name = 'repository' |
95 |
95 |
96 cubicweb_appobject_path = CubicWebConfiguration.cubicweb_appobject_path | set(['sobjects', 'hooks']) |
96 cubicweb_appobject_path = CubicWebConfiguration.cubicweb_appobject_path | set(['sobjects', 'hooks']) |
97 cube_appobject_path = CubicWebConfiguration.cube_appobject_path | set(['sobjects', 'hooks']) |
97 cube_appobject_path = CubicWebConfiguration.cube_appobject_path | set(['sobjects', 'hooks']) |
98 |
98 |
99 options = merge_options(( |
99 options = lgconfig.merge_options(( |
100 # ctl configuration |
100 # ctl configuration |
101 ('host', |
101 ('host', |
102 {'type' : 'string', |
102 {'type' : 'string', |
103 'default': None, |
103 'default': None, |
104 'help': 'host name if not correctly detectable through gethostname', |
104 'help': 'host name if not correctly detectable through gethostname', |
331 stream = open(sourcesfile, 'w') |
331 stream = open(sourcesfile, 'w') |
332 for section in ('admin', 'system'): |
332 for section in ('admin', 'system'): |
333 sconfig = sourcescfg[section] |
333 sconfig = sourcescfg[section] |
334 if isinstance(sconfig, dict): |
334 if isinstance(sconfig, dict): |
335 # get a Configuration object |
335 # get a Configuration object |
336 assert section == 'system' |
336 assert section == 'system', '%r is not system' % section |
337 _sconfig = SourceConfiguration( |
337 _sconfig = SourceConfiguration( |
338 self, options=SOURCE_TYPES['native'].options) |
338 self, options=SOURCE_TYPES['native'].options) |
339 for attr, val in sconfig.items(): |
339 for attr, val in sconfig.items(): |
340 try: |
340 try: |
341 _sconfig.set_option(attr, val) |
341 _sconfig.set_option(attr, val) |
342 except lgconfig.OptionError: |
342 except lgconfig.OptionError: |
343 # skip adapter, may be present on pre 3.10 instances |
343 # skip adapter, may be present on pre 3.10 instances |
344 if attr != 'adapter': |
344 if attr != 'adapter': |
345 self.error('skip unknown option %s in sources file') |
345 self.error('skip unknown option %s in sources file' % attr) |
346 sconfig = _sconfig |
346 sconfig = _sconfig |
347 stream.write('[%s]\n%s\n' % (section, generate_source_config(sconfig))) |
347 stream.write('[%s]\n%s\n' % (section, generate_source_config(sconfig))) |
348 restrict_perms_to_user(sourcesfile) |
348 restrict_perms_to_user(sourcesfile) |
349 |
349 |
350 def pyro_enabled(self): |
350 def pyro_enabled(self): |