Mercurial > public > src > rhodecode
comparison pylons_app/lib/utils.py @ 413:55377fdc1fc6
cleared global application settings.
Made it much more extensible by keeping it key/value in the database.
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sun, 01 Aug 2010 18:36:00 +0200 |
parents | a26f48ad7a8a |
children | a9a607a58b1c |
comparison
equal
deleted
inserted
replaced
412:ca54622e39a1 | 413:55377fdc1fc6 |
---|---|
98 | 98 |
99 | 99 |
100 def get_hg_settings(): | 100 def get_hg_settings(): |
101 try: | 101 try: |
102 sa = meta.Session | 102 sa = meta.Session |
103 ret = sa.query(HgAppSettings).scalar() | 103 ret = sa.query(HgAppSettings).all() |
104 finally: | 104 finally: |
105 meta.Session.remove() | 105 meta.Session.remove() |
106 | 106 |
107 if not ret: | 107 if not ret: |
108 raise Exception('Could not get application settings !') | 108 raise Exception('Could not get application settings !') |
109 return ret | 109 settings = {} |
110 for each in ret: | |
111 settings['hg_app_' + each.app_settings_name] = each.app_settings_value | |
112 | |
113 return settings | |
110 | 114 |
111 def make_ui(read_from='file', path=None, checkpaths=True): | 115 def make_ui(read_from='file', path=None, checkpaths=True): |
112 """ | 116 """ |
113 A function that will read python rc files or database | 117 A function that will read python rc files or database |
114 and make an mercurial ui object from read options | 118 and make an mercurial ui object from read options |
153 return baseui | 157 return baseui |
154 | 158 |
155 | 159 |
156 def set_hg_app_config(config): | 160 def set_hg_app_config(config): |
157 hgsettings = get_hg_settings() | 161 hgsettings = get_hg_settings() |
158 config['hg_app_auth_realm'] = hgsettings.app_auth_realm | 162 |
159 config['hg_app_name'] = hgsettings.app_title | 163 for k, v in hgsettings.items(): |
164 config[k] = v | |
160 | 165 |
161 def invalidate_cache(name, *args): | 166 def invalidate_cache(name, *args): |
162 """Invalidates given name cache""" | 167 """Invalidates given name cache""" |
163 | 168 |
164 from beaker.cache import region_invalidate | 169 from beaker.cache import region_invalidate |