diff roundup/admin.py @ 5817:bed579f654ee maint-1.6

issue2551029: Jinja2 template install error. Issue where template's config.ini not getting updated. Change do_install in admin.py to load config_ini.ini from template before writing tracker's config.ini. This generates an updated config file for the user on install preserving values required tomake tracker work. Added config_ini.ini files to jinja2 and responsive templates to set required values (template_engine and static_files; static_files resp.). Documented new file in doc/tracker_templates.txt and added tests for new admin.py code.
author John Rouillard <rouilj@ieee.org>
date Tue, 04 Jun 2019 18:42:05 -0400
parents ac7fe3483206
children
line wrap: on
line diff
--- a/roundup/admin.py	Sat Jun 01 21:39:17 2019 -0400
+++ b/roundup/admin.py	Tue Jun 04 18:42:05 2019 -0400
@@ -28,7 +28,7 @@
 from roundup import date, hyperdb, roundupdb, init, password, token
 from roundup import __version__ as roundup_version
 import roundup.instance
-from roundup.configuration import CoreConfig, NoConfigError
+from roundup.configuration import CoreConfig, NoConfigError, UserConfig
 from roundup.i18n import _
 from roundup.exceptions import UsageError
 
@@ -429,9 +429,31 @@
             defns = {}
 
         defns['rdbms_backend'] = backend
+
+        # load config_ini.ini from template if it exists.
+        # it sets parameters like template_engine that are
+        # template specific.
+        template_config=UserConfig(templates[template]['path'] +
+                                   "/config_ini.ini")
+        for k in template_config.keys():
+            if k == 'HOME': # ignore home. It is a default param.
+                continue
+            defns[k] = template_config[k]
+
         # install!
         init.install(tracker_home, templates[template]['path'], settings=defns)
 
+        # Remove config_ini.ini file from tracker_home (not template dir).
+        # Ignore file not found - not all templates have
+        #   config_ini.ini files.
+        try:
+            os.remove(tracker_home + "/config_ini.ini")
+        except OSError as e:  # FileNotFound exception under py3
+            if e.errno == 2:
+                pass
+            else:
+                raise
+
         print(_("""
 ---------------------------------------------------------------------------
  You should now edit the tracker configuration file:

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