__init__.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import threading
  2. from os import path
  3. basedir = path.dirname(path.realpath(__file__))
  4. """
  5. Base directory for the module.
  6. This can be used by modules looking for configuration and data files to be
  7. referenced or copied with a known path relative to the package root.
  8. :rtype: str
  9. """
  10. class Env:
  11. pass
  12. env = Env()
  13. """
  14. A pox on "globals are evil".
  15. All-purpose bucket for storing global variables. Different environments
  16. (e.g. webapp, test suite) put the appropriate value in it.
  17. The most important values to be stored are app_conf (either from
  18. lakesuperior.config_parser.config or lakesuperior.config_parser.test_config)
  19. and app_globals (obtained by an instance of lakesuperior.globals.AppGlobals).
  20. e.g.::
  21. >>> from lakesuperior.config_parser import config
  22. >>> from lakesuperior.globals import AppGlobals
  23. >>> from lakesuperior import env
  24. >>> env.app_globals = AppGlobals(config)
  25. This is automated in non-test environments by importing
  26. `lakesuperior.env_setup`.
  27. :rtype: Object
  28. """
  29. thread_env = threading.local()
  30. """
  31. Thread-local environment.
  32. This is used to store thread-specific variables such as start/end request
  33. timestamps.
  34. :rtype: threading.local
  35. """