comparison roundup/configuration.py @ 5748:943e61bc26d5

Fix issue2551029 (Jinja2 template install error) by deleting config.ini from all templates. Looks like classic and minimal never included a config.ini. Presence of config.ini stopped 'roundup-admin install' from generating an up to date config.ini. Created special option class for backend database. Comment now uses roundup.backend.list_backends to give user indication of valid values. Also we now get an error if user specifies invalid backend. Moved backend setting to top or [rdbms] section. It is the most important thing in there and if set to anydbm (or some other non-rdbm) the rest of the settings can be ignored. Change rdbms config section comment to indicate that the backend setting was used by other database backends. (e.g. if set to anydbm).
author John Rouillard <rouilj@ieee.org>
date Sat, 01 Jun 2019 09:05:23 -0400
parents 1b5bcc5d745f
children 178ca608ddb9
comparison
equal deleted inserted replaced
5747:17b38e209307 5748:943e61bc26d5
24 import roundup.date 24 import roundup.date
25 25
26 from roundup.anypy.strings import b2s 26 from roundup.anypy.strings import b2s
27 import roundup.anypy.random_ as random_ 27 import roundup.anypy.random_ as random_
28 import binascii 28 import binascii
29
30 from roundup.backends import list_backends
29 31
30 # XXX i don't think this module needs string translation, does it? 32 # XXX i don't think this module needs string translation, does it?
31 33
32 ### Exceptions 34 ### Exceptions
33 35
334 if _val in ("strict", "lax", "none"): 336 if _val in ("strict", "lax", "none"):
335 return _val.capitalize() 337 return _val.capitalize()
336 else: 338 else:
337 raise OptionValueError(self, value, self.class_description) 339 raise OptionValueError(self, value, self.class_description)
338 340
341 class DatabaseBackend(Option):
342 """handle exact text of backend and make sure it's available"""
343 class_description = "Available backends: %s"%", ".join(list_backends())
344
345 def str2value(self, value):
346 _val = value.lower()
347 if _val in list_backends():
348 return _val
349 else:
350 raise OptionValueError(self, value, self.class_description)
351
339 class HtmlToTextOption(Option): 352 class HtmlToTextOption(Option):
340 353
341 """What module should be used to convert emails with only text/html parts into text for display in roundup. Choose from beautifulsoup 4, dehtml - the internal code or none to disable html to text conversion. If beautifulsoup chosen but not available, dehtml will be used.""" 354 """What module should be used to convert emails with only text/html parts into text for display in roundup. Choose from beautifulsoup 4, dehtml - the internal code or none to disable html to text conversion. If beautifulsoup chosen but not available, dehtml will be used."""
342 355
343 class_description = "Allowed values: beautifulsoup, dehtml, none" 356 class_description = "Allowed values: beautifulsoup, dehtml, none"
892 "(Note the default value changes every time\n" 905 "(Note the default value changes every time\n"
893 " roundup-admin updateconfig\n" 906 " roundup-admin updateconfig\n"
894 "is run, so it must be explicitly set to a non-empty string.\n"), 907 "is run, so it must be explicitly set to a non-empty string.\n"),
895 )), 908 )),
896 ("rdbms", ( 909 ("rdbms", (
910 (DatabaseBackend, 'backend', NODEFAULT,
911 "Database backend."),
897 (Option, 'name', 'roundup', 912 (Option, 'name', 'roundup',
898 "Name of the database to use.", 913 "Name of the database to use.",
899 ['MYSQL_DBNAME']), 914 ['MYSQL_DBNAME']),
900 (Option, 'backend', '',
901 "Database backend."),
902 (NullableOption, 'host', 'localhost', 915 (NullableOption, 'host', 'localhost',
903 "Database server host.", 916 "Database server host.",
904 ['MYSQL_DBHOST']), 917 ['MYSQL_DBHOST']),
905 (NullableOption, 'port', '', 918 (NullableOption, 'port', '',
906 "TCP port number of the database server.\n" 919 "TCP port number of the database server.\n"
945 "error message."), 958 "error message."),
946 (IsolationOption, 'isolation_level', 'read committed', 959 (IsolationOption, 'isolation_level', 'read committed',
947 "Database isolation level, currently supported for\n" 960 "Database isolation level, currently supported for\n"
948 "PostgreSQL and mysql. See, e.g.,\n" 961 "PostgreSQL and mysql. See, e.g.,\n"
949 "http://www.postgresql.org/docs/9.1/static/transaction-iso.html"), 962 "http://www.postgresql.org/docs/9.1/static/transaction-iso.html"),
950 ), "Settings in this section are used" 963 ), "Settings in this section (except for backend) are used"
951 " by RDBMS backends only" 964 " by RDBMS backends only."
952 ), 965 ),
953 ("logging", ( 966 ("logging", (
954 (FilePathOption, "config", "", 967 (FilePathOption, "config", "",
955 "Path to configuration file for standard Python logging module.\n" 968 "Path to configuration file for standard Python logging module.\n"
956 "If this option is set, logging configuration is loaded\n" 969 "If this option is set, logging configuration is loaded\n"

Roundup Issue Tracker: http://roundup-tracker.org/