comparison roundup/admin.py @ 5762:b76be13e027e

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 bb7865241f8a
children d0aebd4aec72
comparison
equal deleted inserted replaced
5760:f0ca4daf6a18 5762:b76be13e027e
26 import csv, getopt, getpass, os, re, shutil, sys, operator 26 import csv, getopt, getpass, os, re, shutil, sys, operator
27 27
28 from roundup import date, hyperdb, roundupdb, init, password, token 28 from roundup import date, hyperdb, roundupdb, init, password, token
29 from roundup import __version__ as roundup_version 29 from roundup import __version__ as roundup_version
30 import roundup.instance 30 import roundup.instance
31 from roundup.configuration import CoreConfig, NoConfigError 31 from roundup.configuration import CoreConfig, NoConfigError, UserConfig
32 from roundup.i18n import _ 32 from roundup.i18n import _
33 from roundup.exceptions import UsageError 33 from roundup.exceptions import UsageError
34 from roundup.anypy.my_input import my_input 34 from roundup.anypy.my_input import my_input
35 from roundup.anypy.strings import repr_export 35 from roundup.anypy.strings import repr_export
36 36
428 raise 428 raise
429 else: 429 else:
430 defns = {} 430 defns = {}
431 431
432 defns['rdbms_backend'] = backend 432 defns['rdbms_backend'] = backend
433
434 # load config_ini.ini from template if it exists.
435 # it sets parameters like template_engine that are
436 # template specific.
437 template_config=UserConfig(templates[template]['path'] +
438 "/config_ini.ini")
439 for k in template_config.keys():
440 if k == 'HOME': # ignore home. It is a default param.
441 continue
442 defns[k] = template_config[k]
443
433 # install! 444 # install!
434 init.install(tracker_home, templates[template]['path'], settings=defns) 445 init.install(tracker_home, templates[template]['path'], settings=defns)
446
447 # Remove config_ini.ini file from tracker_home (not template dir).
448 # Ignore file not found - not all templates have
449 # config_ini.ini files.
450 try:
451 os.remove(tracker_home + "/config_ini.ini")
452 except OSError as e: # FileNotFound exception under py3
453 if e.errno == 2:
454 pass
455 else:
456 raise
435 457
436 print(_(""" 458 print(_("""
437 --------------------------------------------------------------------------- 459 ---------------------------------------------------------------------------
438 You should now edit the tracker configuration file: 460 You should now edit the tracker configuration file:
439 %(config_file)s""") % {"config_file": config_ini_file}) 461 %(config_file)s""") % {"config_file": config_ini_file})

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