Mercurial > p > roundup > code
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 5758:392f887652f0 | 5817:bed579f654ee |
|---|---|
| 26 import csv, getopt, getpass, os, re, shutil, sys, UserDict, operator | 26 import csv, getopt, getpass, os, re, shutil, sys, UserDict, 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 | 34 |
| 35 # Polyglot code | 35 # Polyglot code |
| 36 try: | 36 try: |
| 427 raise | 427 raise |
| 428 else: | 428 else: |
| 429 defns = {} | 429 defns = {} |
| 430 | 430 |
| 431 defns['rdbms_backend'] = backend | 431 defns['rdbms_backend'] = backend |
| 432 | |
| 433 # load config_ini.ini from template if it exists. | |
| 434 # it sets parameters like template_engine that are | |
| 435 # template specific. | |
| 436 template_config=UserConfig(templates[template]['path'] + | |
| 437 "/config_ini.ini") | |
| 438 for k in template_config.keys(): | |
| 439 if k == 'HOME': # ignore home. It is a default param. | |
| 440 continue | |
| 441 defns[k] = template_config[k] | |
| 442 | |
| 432 # install! | 443 # install! |
| 433 init.install(tracker_home, templates[template]['path'], settings=defns) | 444 init.install(tracker_home, templates[template]['path'], settings=defns) |
| 445 | |
| 446 # Remove config_ini.ini file from tracker_home (not template dir). | |
| 447 # Ignore file not found - not all templates have | |
| 448 # config_ini.ini files. | |
| 449 try: | |
| 450 os.remove(tracker_home + "/config_ini.ini") | |
| 451 except OSError as e: # FileNotFound exception under py3 | |
| 452 if e.errno == 2: | |
| 453 pass | |
| 454 else: | |
| 455 raise | |
| 434 | 456 |
| 435 print(_(""" | 457 print(_(""" |
| 436 --------------------------------------------------------------------------- | 458 --------------------------------------------------------------------------- |
| 437 You should now edit the tracker configuration file: | 459 You should now edit the tracker configuration file: |
| 438 %(config_file)s""") % {"config_file": config_ini_file}) | 460 %(config_file)s""") % {"config_file": config_ini_file}) |
