Mercurial > kallithea
comparison pylons_app/lib/utils.py @ 388:3bcf9529d221
Added new application settings,Push ssl and repositories path
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Thu, 05 Aug 2010 22:31:23 +0200 |
parents | a9a607a58b1c |
children | b27d32cb3157 |
comparison
equal
deleted
inserted
replaced
387:2a18192fbd1e | 388:3bcf9529d221 |
---|---|
110 for each in ret: | 110 for each in ret: |
111 settings['hg_app_' + each.app_settings_name] = each.app_settings_value | 111 settings['hg_app_' + each.app_settings_name] = each.app_settings_value |
112 | 112 |
113 return settings | 113 return settings |
114 | 114 |
115 def get_hg_ui_settings(): | |
116 try: | |
117 sa = meta.Session | |
118 ret = sa.query(HgAppUi).all() | |
119 finally: | |
120 meta.Session.remove() | |
121 | |
122 if not ret: | |
123 raise Exception('Could not get application ui settings !') | |
124 settings = {} | |
125 for each in ret: | |
126 k = each.ui_key if each.ui_key != '/' else 'root_path' | |
127 settings[each.ui_section + '_' + k] = each.ui_value | |
128 | |
129 return settings | |
130 | |
131 #propagated from mercurial documentation | |
115 ui_sections = ['alias', 'auth', | 132 ui_sections = ['alias', 'auth', |
116 'decode/encode', 'defaults', | 133 'decode/encode', 'defaults', |
117 'diff', 'email', | 134 'diff', 'email', |
118 'extensions', 'format', | 135 'extensions', 'format', |
119 'merge-patterns', 'merge-tools', | 136 'merge-patterns', 'merge-tools', |
130 | 147 |
131 @param path: path to mercurial config file | 148 @param path: path to mercurial config file |
132 @param checkpaths: check the path | 149 @param checkpaths: check the path |
133 @param read_from: read from 'file' or 'db' | 150 @param read_from: read from 'file' or 'db' |
134 """ | 151 """ |
135 #propagated from mercurial documentation | |
136 | 152 |
137 baseui = ui.ui() | 153 baseui = ui.ui() |
138 | 154 |
139 | |
140 if read_from == 'file': | 155 if read_from == 'file': |
141 if not os.path.isfile(path): | 156 if not os.path.isfile(path): |
142 log.warning('Unable to read config file %s' % path) | 157 log.warning('Unable to read config file %s' % path) |
143 return False | 158 return False |
144 | 159 log.debug('reading hgrc from %s', path) |
145 cfg = config.config() | 160 cfg = config.config() |
146 cfg.read(path) | 161 cfg.read(path) |
147 for section in ui_sections: | 162 for section in ui_sections: |
148 for k, v in cfg.items(section): | 163 for k, v in cfg.items(section): |
149 baseui.setconfig(section, k, v) | 164 baseui.setconfig(section, k, v) |
165 log.debug('settings ui from file[%s]%s:%s', section, k, v) | |
150 if checkpaths:check_repo_dir(cfg.items('paths')) | 166 if checkpaths:check_repo_dir(cfg.items('paths')) |
151 | 167 |
152 | 168 |
153 elif read_from == 'db': | 169 elif read_from == 'db': |
154 hg_ui = get_hg_ui_cached() | 170 hg_ui = get_hg_ui_cached() |
155 for ui_ in hg_ui: | 171 for ui_ in hg_ui: |
172 log.debug('settings ui from db[%s]%s:%s', ui_.ui_section, ui_.ui_key, ui_.ui_value) | |
156 baseui.setconfig(ui_.ui_section, ui_.ui_key, ui_.ui_value) | 173 baseui.setconfig(ui_.ui_section, ui_.ui_key, ui_.ui_value) |
157 | 174 |
158 | 175 |
159 return baseui | 176 return baseui |
160 | 177 |