diff --git a/docs/setup.rst b/docs/setup.rst --- a/docs/setup.rst +++ b/docs/setup.rst @@ -16,7 +16,9 @@ following command to do so:: This will create the file ``my.ini`` in the current directory. This configuration file contains the various settings for Kallithea, e.g. proxy port, email settings, usage of static files, cache, Celery -settings, and logging. +settings, and logging. Extra settings can be specified like:: + + gearbox make-config my.ini host=8.8.8.8 "[handler_console]" formatter=color_formatter Next, you need to create the databases used by Kallithea. It is recommended to use PostgreSQL or SQLite (default). If you choose a database other than the diff --git a/kallithea/lib/paster_commands/make_config.py b/kallithea/lib/paster_commands/make_config.py --- a/kallithea/lib/paster_commands/make_config.py +++ b/kallithea/lib/paster_commands/make_config.py @@ -25,6 +25,7 @@ import os import sys import uuid import argparse +from collections import defaultdict import mako.exceptions @@ -42,6 +43,11 @@ class Command(BasePasterCommand): second phase is setup-app). make-config creates a bare configuration file (possibly filling in defaults from the extra variables you give). + + The first key=value arguments are used to customize the Mako variables that + are shown with --show-defaults. The following settings will be + patched/inserted in the [app:main] section ... until another section name + is specified and change where the following values go. """ takes_config_file = False # at least not an existing one ... @@ -73,12 +79,21 @@ def _run(args): raise ValueError("Can't specify both config_file and --show_defaults") mako_variable_values = {} + ini_settings = defaultdict(dict) + section_name = None for parameter in args.custom: parts = parameter.split('=', 1) - if len(parts) == 2: + if len(parts) == 1 and parameter.startswith('[') and parameter.endswith(']'): + section_name = parameter + elif len(parts) == 2: key, value = parts - mako_variable_values[key] = value + if section_name is None and key in inifile.default_variables: + mako_variable_values[key] = value + else: + if section_name is None: + section_name = '[app:main]' + ini_settings[section_name][key] = value else: raise ValueError("Invalid name=value parameter %r" % parameter) @@ -94,7 +109,7 @@ def _run(args): }) try: config_file = os.path.abspath(args.config_file) - inifile.create(config_file, mako_variable_values, {}) + inifile.create(config_file, mako_variable_values, ini_settings) print 'Wrote new config file in %s' % config_file except Exception: