Show More
@@ -1,13 +1,10 b'' | |||
|
1 | 1 | """The application's Globals object""" |
|
2 | 2 | #uncomment the following if you want to serve a single repo |
|
3 | 3 | #from mercurial.hgweb.hgweb_mod import hgweb |
|
4 | from mercurial.hgweb.hgwebdir_mod import hgwebdir | |
|
5 | from mercurial import templater | |
|
6 | from mercurial.hgweb.request import wsgiapplication | |
|
7 | from mercurial import ui, config | |
|
8 | 4 | import os |
|
9 | 5 | from beaker.cache import CacheManager |
|
10 | 6 | from beaker.util import parse_cache_config_options |
|
7 | from pylons_app.lib.utils import make_ui | |
|
11 | 8 | |
|
12 | 9 | class Globals(object): |
|
13 | 10 | |
@@ -23,70 +20,6 b' class Globals(object):' | |||
|
23 | 20 | |
|
24 | 21 | """ |
|
25 | 22 | self.cache = CacheManager(**parse_cache_config_options(config)) |
|
26 |
self.baseui = |
|
|
27 | ||
|
28 | ||
|
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 | |
|
60 | baseui = ui.ui() | |
|
61 | cfg = config.config() | |
|
62 | cfg.read(repos) | |
|
63 | self.paths = cfg.items('paths') | |
|
23 | self.baseui = make_ui('hgwebdir.config') | |
|
24 | self.paths = self.baseui.configitems('paths') | |
|
64 | 25 | self.base_path = self.paths[0][1].replace('*', '') |
|
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) | |
|
71 | ||
|
72 | return baseui | |
|
73 | ||
|
74 | def set_statics(self, cfg): | |
|
75 | ''' | |
|
76 | set's the statics for use in mako templates | |
|
77 | @param cfg: | |
|
78 | ''' | |
|
79 | self.statics = cfg.get('web', 'staticurl', '/static') | |
|
80 | if not self.statics.endswith('/'): | |
|
81 | self.statics += '/' | |
|
82 | ||
|
83 | ||
|
84 | def check_repo_dir(self, paths): | |
|
85 | repos_path = paths[0][1].split('/') | |
|
86 | if repos_path[-1] in ['*', '**']: | |
|
87 | repos_path = repos_path[:-1] | |
|
88 | if repos_path[0] != '/': | |
|
89 | repos_path[0] = '/' | |
|
90 | if not os.path.isdir(os.path.join(*repos_path)): | |
|
91 | raise Exception('Not a valid repository in %s' % paths[0][1]) | |
|
92 |
General Comments 0
You need to be logged in to leave comments.
Login now