config.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 unicode_literals, absolute_import
  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()