__init__.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import threading
  2. from os import path
  3. version = '1.0 alpha'
  4. release = '1.0.0a18'
  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. pass
  14. env = Env()
  15. """
  16. A pox on "globals are evil".
  17. All-purpose bucket for storing global variables. Different environments
  18. (e.g. webapp, test suite) put the appropriate value in it.
  19. The most important values to be stored are app_conf (either from
  20. lakesuperior.config_parser.config or lakesuperior.config_parser.test_config)
  21. and app_globals (obtained by an instance of lakesuperior.globals.AppGlobals).
  22. e.g.::
  23. >>> from lakesuperior.config_parser import config
  24. >>> from lakesuperior.globals import AppGlobals
  25. >>> from lakesuperior import env
  26. >>> env.app_globals = AppGlobals(config)
  27. This is automated in non-test environments by importing
  28. `lakesuperior.env_setup`.
  29. :rtype: Object
  30. """
  31. thread_env = threading.local()
  32. """
  33. Thread-local environment.
  34. This is used to store thread-specific variables such as start/end request
  35. timestamps.
  36. :rtype: threading.local
  37. """