##// 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 This will create the file ``my.ini`` in the current directory. This
16 This will create the file ``my.ini`` in the current directory. This
17 configuration file contains the various settings for Kallithea, e.g.
17 configuration file contains the various settings for Kallithea, e.g.
18 proxy port, email settings, usage of static files, cache, Celery
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 Next, you need to create the databases used by Kallithea. It is recommended to
23 Next, you need to create the databases used by Kallithea. It is recommended to
22 use PostgreSQL or SQLite (default). If you choose a database other than the
24 use PostgreSQL or SQLite (default). If you choose a database other than the
@@ -25,6 +25,7 b' import os'
25 import sys
25 import sys
26 import uuid
26 import uuid
27 import argparse
27 import argparse
28 from collections import defaultdict
28
29
29 import mako.exceptions
30 import mako.exceptions
30
31
@@ -42,6 +43,11 b' class Command(BasePasterCommand):'
42 second phase is setup-app). make-config creates a bare configuration
43 second phase is setup-app). make-config creates a bare configuration
43 file (possibly filling in defaults from the extra
44 file (possibly filling in defaults from the extra
44 variables you give).
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 takes_config_file = False # at least not an existing one ...
53 takes_config_file = False # at least not an existing one ...
@@ -73,12 +79,21 b' def _run(args):'
73 raise ValueError("Can't specify both config_file and --show_defaults")
79 raise ValueError("Can't specify both config_file and --show_defaults")
74
80
75 mako_variable_values = {}
81 mako_variable_values = {}
82 ini_settings = defaultdict(dict)
76
83
84 section_name = None
77 for parameter in args.custom:
85 for parameter in args.custom:
78 parts = parameter.split('=', 1)
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 key, value = parts
90 key, value = parts
81 mako_variable_values[key] = value
91 if section_name is None and key in inifile.default_variables:
92 mako_variable_values[key] = value
93 else:
94 if section_name is None:
95 section_name = '[app:main]'
96 ini_settings[section_name][key] = value
82 else:
97 else:
83 raise ValueError("Invalid name=value parameter %r" % parameter)
98 raise ValueError("Invalid name=value parameter %r" % parameter)
84
99
@@ -94,7 +109,7 b' def _run(args):'
94 })
109 })
95 try:
110 try:
96 config_file = os.path.abspath(args.config_file)
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 print 'Wrote new config file in %s' % config_file
113 print 'Wrote new config file in %s' % config_file
99
114
100 except Exception:
115 except Exception:
General Comments 0
You need to be logged in to leave comments. Login now