__init__.py 1.4 KB

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