0001-flatten-site-options-so-they-can-be-used-in-string-t.patch
wcsinst/wcsinstd/deploy.py | ||
---|---|---|
18 | 18 |
def get_provider_key(provider_id): |
19 | 19 |
return provider_id.replace('://', '-').replace('/', '-').replace('?', '-').replace(':', '-') |
20 | 20 | |
21 |
def flatten_dict(d): |
|
22 |
for k, v in d.items(): |
|
23 |
if type(v) is dict: |
|
24 |
flatten_dict(v) |
|
25 |
for k2, v2 in v.items(): |
|
26 |
d['%s_%s' % (k, k2)] = v2 |
|
27 |
del d[k] |
|
28 |
return d |
|
29 | ||
21 | 30 | |
22 | 31 |
class DeployInstance(object): |
23 | 32 |
skeleton = 'default' |
... | ... | |
206 | 215 |
if not os.path.exists(options_template_path): |
207 | 216 |
return |
208 | 217 |
options_template = file(options_template_path).read() |
218 |
vars = {'domain': self.domain} |
|
219 |
if self.site_options_cfg: |
|
220 |
vars.update(flatten_dict(self.site_options_cfg)) |
|
209 | 221 |
file(os.path.join(self.collectivity_install_dir, 'site-options.cfg'), 'w').write( |
210 |
string.Template(options_template).substitute({ |
|
211 |
'domain': self.domain, |
|
212 |
'options': self.site_options_cfg |
|
213 |
}) |
|
214 |
) |
|
222 |
string.Template(options_template).substitute(vars)) |
|
215 | 223 | |
216 | 224 | |
217 | 225 |
def make_apache_vhost(self): |
218 |
- |