Skip to content

Commit 4e92dc9

Browse files
committed
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).
1 parent da63581 commit 4e92dc9

File tree

5 files changed

+21
-1162
lines changed

5 files changed

+21
-1162
lines changed

CHANGES.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@ Fixed:
131131
- issue2551033: prevent reverse engineering hidden data by using etags
132132
as an oracle to identify when the right data has been
133133
guessed. (Joseph Myers, John Rouillard)
134+
- issue2551029: Jinja2 template install error. Update configuration
135+
code to make sure valid backend database is set. Remove config.ini
136+
from templates to make sure that roundup-admin install writes a new
137+
default config.ini based on configuration.py.
134138

135139
2018-07-13 1.6.0
136140

roundup/configuration.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
import roundup.anypy.random_ as random_
2828
import binascii
2929

30+
from roundup.backends import list_backends
31+
3032
# XXX i don't think this module needs string translation, does it?
3133

3234
### Exceptions
@@ -336,6 +338,17 @@ def str2value(self, value):
336338
else:
337339
raise OptionValueError(self, value, self.class_description)
338340

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+
339352
class HtmlToTextOption(Option):
340353

341354
"""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."""
@@ -894,11 +907,11 @@ def str2value(self, value):
894907
"is run, so it must be explicitly set to a non-empty string.\n"),
895908
)),
896909
("rdbms", (
910+
(DatabaseBackend, 'backend', NODEFAULT,
911+
"Database backend."),
897912
(Option, 'name', 'roundup',
898913
"Name of the database to use.",
899914
['MYSQL_DBNAME']),
900-
(Option, 'backend', '',
901-
"Database backend."),
902915
(NullableOption, 'host', 'localhost',
903916
"Database server host.",
904917
['MYSQL_DBHOST']),
@@ -947,8 +960,8 @@ def str2value(self, value):
947960
"Database isolation level, currently supported for\n"
948961
"PostgreSQL and mysql. See, e.g.,\n"
949962
"http://www.postgresql.org/docs/9.1/static/transaction-iso.html"),
950-
), "Settings in this section are used"
951-
" by RDBMS backends only"
963+
), "Settings in this section (except for backend) are used"
964+
" by RDBMS backends only."
952965
),
953966
("logging", (
954967
(FilePathOption, "config", "",

0 commit comments

Comments
 (0)