PageRenderTime 217ms CodeModel.GetById 120ms app.highlight 5ms RepoModel.GetById 90ms app.codeStats 0ms

/kai/lib/app_globals.py

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