##// END OF EJS Templates
make-config: allow configuration of any ini value...
Mads Kiilerich -
r6823:a8b9f2d6 default
parent child Browse files
Show More
@@ -16,7 +16,9 b' following command to do so::'
16 16 This will create the file ``my.ini`` in the current directory. This
17 17 configuration file contains the various settings for Kallithea, e.g.
18 18 proxy port, email settings, usage of static files, cache, Celery
19 settings, and logging.
19 settings, and logging. Extra settings can be specified like::
20
21 gearbox make-config my.ini host=8.8.8.8 "[handler_console]" formatter=color_formatter
20 22
21 23 Next, you need to create the databases used by Kallithea. It is recommended to
22 24 use PostgreSQL or SQLite (default). If you choose a database other than the
@@ -25,6 +25,7 b' import os'
25 25 import sys
26 26 import uuid
27 27 import argparse
28 from collections import defaultdict
28 29
29 30 import mako.exceptions
30 31
@@ -42,6 +43,11 b' class Command(BasePasterCommand):'
42 43 second phase is setup-app). make-config creates a bare configuration
43 44 file (possibly filling in defaults from the extra
44 45 variables you give).
46
47 The first key=value arguments are used to customize the Mako variables that
48 are shown with --show-defaults. The following settings will be
49 patched/inserted in the [app:main] section ... until another section name
50 is specified and change where the following values go.
45 51 """
46 52
47 53 takes_config_file = False # at least not an existing one ...
@@ -73,13 +79,22 b' def _run(args):'
73 79 raise ValueError("Can't specify both config_file and --show_defaults")
74 80
75 81 mako_variable_values = {}
82 ini_settings = defaultdict(dict)
76 83
84 section_name = None
77 85 for parameter in args.custom:
78 86 parts = parameter.split('=', 1)
79 if len(parts) == 2:
87 if len(parts) == 1 and parameter.startswith('[') and parameter.endswith(']'):
88 section_name = parameter
89 elif len(parts) == 2:
80 90 key, value = parts
91 if section_name is None and key in inifile.default_variables:
81 92 mako_variable_values[key] = value
82 93 else:
94 if section_name is None:
95 section_name = '[app:main]'
96 ini_settings[section_name][key] = value
97 else:
83 98 raise ValueError("Invalid name=value parameter %r" % parameter)
84 99
85 100 if args.show_defaults:
@@ -94,7 +109,7 b' def _run(args):'
94 109 })
95 110 try:
96 111 config_file = os.path.abspath(args.config_file)
97 inifile.create(config_file, mako_variable_values, {})
112 inifile.create(config_file, mako_variable_values, ini_settings)
98 113 print 'Wrote new config file in %s' % config_file
99 114
100 115 except Exception:
General Comments 0
You need to be logged in to leave comments. Login now