comparison pylons_app/lib/app_globals.py @ 93:aec4c0071cb3

added empty controllers for branches tags files graph, routing and test for them
author Marcin Kuzminski <marcin@python-works.com>
date Wed, 21 Apr 2010 00:26:11 +0200
parents 928416088790
children f7c403e89d5b
comparison
equal deleted inserted replaced
92:2968fb635787 93:aec4c0071cb3
21 initialization and is available during requests via the 21 initialization and is available during requests via the
22 'app_globals' variable 22 'app_globals' variable
23 23
24 """ 24 """
25 self.cache = CacheManager(**parse_cache_config_options(config)) 25 self.cache = CacheManager(**parse_cache_config_options(config))
26 self.hgapp = wsgiapplication(self.make_web_app) 26 self.baseui = self.make_ui('hgwebdir.config')
27 27
28 def make_web_app(self): 28
29 repos = "hgwebdir.config" 29 def make_ui(self, path='hgwebdir.config'):
30 """
31 A funcion that will read python rc files and make an ui from read options
32
33 @param path: path to mercurial config file
34 """
35 #propagated from mercurial documentation
36 sections = [
37 'alias',
38 'auth',
39 'decode/encode',
40 'defaults',
41 'diff',
42 'email',
43 'extensions',
44 'format',
45 'merge-patterns',
46 'merge-tools',
47 'hooks',
48 'http_proxy',
49 'smtp',
50 'patch',
51 'paths',
52 'profiling',
53 'server',
54 'trusted',
55 'ui',
56 'web',
57 ]
58
59 repos = path
30 baseui = ui.ui() 60 baseui = ui.ui()
31 cfg = config.config() 61 cfg = config.config()
32 cfg.read(repos) 62 cfg.read(repos)
33 paths = cfg.items('paths') 63 self.paths = cfg.items('paths')
34 self.paths = paths 64 self.base_path = self.paths[0][1].replace('*', '')
35 self.check_repo_dir(paths) 65 self.check_repo_dir(self.paths)
66 self.set_statics(cfg)
67
68 for section in sections:
69 for k, v in cfg.items(section):
70 baseui.setconfig(section, k, v)
36 71
37 self.set_statics(cfg) 72 return baseui
38
39 for k, v in cfg.items('web'):
40 baseui.setconfig('web', k, v)
41 #magic trick to make our custom template dir working
42 templater.path.append(cfg.get('web', 'templates', None))
43 self.baseui = baseui
44 #baseui.setconfig('web', 'description', '')
45 #baseui.setconfig('web', 'name', '')
46 #baseui.setconfig('web', 'contact', '')
47 #baseui.setconfig('web', 'allow_archive', '')
48 #baseui.setconfig('web', 'style', 'monoblue_plain')
49 #baseui.setconfig('web', 'baseurl', '')
50 #baseui.setconfig('web', 'staticurl', '')
51
52 hgwebapp = hgwebdir(paths, baseui=baseui)
53 return hgwebapp
54
55 73
56 def set_statics(self, cfg): 74 def set_statics(self, cfg):
57 ''' 75 '''
58 set's the statics for use in mako templates 76 set's the statics for use in mako templates
59 @param cfg: 77 @param cfg: