config.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. # -*- coding: utf-8 -*-
  2. """
  3. (c) 2017 - Copyright Red Hat Inc
  4. Authors:
  5. Pierre-Yves Chibon <pingou@pingoured.fr>
  6. """
  7. from __future__ import absolute_import, unicode_literals
  8. import os # noqa: E402
  9. import flask # noqa: E402
  10. def reload_config():
  11. """Reload the configuration."""
  12. config = flask.config.Config(
  13. os.path.dirname(os.path.abspath(__file__)), flask.Flask.default_config
  14. )
  15. config.from_object("pagure.default_config")
  16. if "PAGURE_CONFIG" in os.environ:
  17. config.from_envvar("PAGURE_CONFIG")
  18. # These were previously respected config values, but as explained
  19. # in https://pagure.io/pagure/issue/2991 they don't really work
  20. # as expected and their values must be based on GIT_FOLDER.
  21. # To prevent large changes throughout the codebase, we omitted them
  22. # from config and we add them here.
  23. if config["ENABLE_DOCS"]:
  24. config["DOCS_FOLDER"] = os.path.join(config["GIT_FOLDER"], "docs")
  25. if config["ENABLE_TICKETS"]:
  26. config["TICKETS_FOLDER"] = os.path.join(
  27. config["GIT_FOLDER"], "tickets"
  28. )
  29. config["REQUESTS_FOLDER"] = os.path.join(config["GIT_FOLDER"], "requests")
  30. if "GITOLITE_BACKEND" in config:
  31. # This is for backwards compatibility purposes
  32. config["GIT_AUTH_BACKEND"] = config["GITOLITE_BACKEND"]
  33. return config
  34. config = reload_config()