/kai/lib/app_globals.py

https://bitbucket.org/bbangert/kai/ · Python · 35 lines · 28 code · 2 blank · 5 comment · 2 complexity · f708603bcc3566336542629a3834ecad MD5 · raw file

  1. """The application's Globals object"""
  2. from datetime import datetime
  3. import md5
  4. import os
  5. from beaker.cache import CacheManager
  6. from beaker.util import parse_cache_config_options
  7. from openid.server import server
  8. from openid.store import filestore
  9. from pylons import config
  10. class Globals(object):
  11. """Globals acts as a container for objects available throughout the
  12. life of the application
  13. """
  14. def __init__(self, config):
  15. """One instance of Globals is created during application
  16. initialization and is available during requests via the
  17. 'app_globals' variable
  18. """
  19. self.cache = CacheManager(**parse_cache_config_options(config))
  20. oid_store = os.path.sep.join([config['pylons.cache_dir'], 'openid'])
  21. self.openid_store = filestore.FileOpenIDStore(oid_store)
  22. self.openid_server = server.Server(self.openid_store, config['openid.base_url'])
  23. self.etag_id = md5.md5(str(datetime.now().timetuple()[3])).hexdigest()
  24. self.versions = ['0.8','0.8.1', '0.8.2', '0.9', '0.9.1', '0.9.2',
  25. '0.9.3', '0.9.4', '0.9.4.1', '0.9.5', '0.9.6', '0.9.6.1',
  26. '0.9.6.2', '0.9.7rc4', '0.9.7rc5', '0.9.7rc6', '0.9.7',
  27. '0.10b1', '1.0b1', '0.10rc1', '0.10', '1.0rc1', '1.0']
  28. self.current_version = '1.0'
  29. self.doc_version = '1.0'