Mercurial > kallithea
comparison pylons_app/lib/utils.py @ 345:bb8f45f6d8f9
updated hg-app db manage and global settings
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Wed, 14 Jul 2010 12:50:12 +0200 |
parents | 6484963056cd |
children | e8fc875467bd |
comparison
equal
deleted
inserted
replaced
344:ab5d91709af9 | 345:bb8f45f6d8f9 |
---|---|
26 | 26 |
27 import os | 27 import os |
28 import logging | 28 import logging |
29 from mercurial import ui, config, hg | 29 from mercurial import ui, config, hg |
30 from mercurial.error import RepoError | 30 from mercurial.error import RepoError |
31 from pylons_app.model.db import Repository, User, HgAppUi | 31 from pylons_app.model.db import Repository, User, HgAppUi, HgAppSettings |
32 from pylons_app.model.meta import Session | |
32 log = logging.getLogger(__name__) | 33 log = logging.getLogger(__name__) |
33 | 34 |
34 | 35 |
35 def get_repo_slug(request): | 36 def get_repo_slug(request): |
36 return request.environ['pylons.routes_dict'].get('repo_name') | 37 return request.environ['pylons.routes_dict'].get('repo_name') |
77 return True | 78 return True |
78 | 79 |
79 | 80 |
80 @cache_region('super_short_term', 'cached_hg_ui') | 81 @cache_region('super_short_term', 'cached_hg_ui') |
81 def get_hg_ui_cached(): | 82 def get_hg_ui_cached(): |
82 from pylons_app.model.meta import Session | |
83 sa = Session() | 83 sa = Session() |
84 return sa.query(HgAppUi).all() | 84 return sa.query(HgAppUi).all() |
85 | 85 |
86 def get_hg_settings(): | |
87 sa = Session() | |
88 ret = sa.query(HgAppSettings).scalar() | |
89 if not ret: | |
90 raise Exception('Could not get application settings !') | |
91 return ret | |
92 | |
86 def make_ui(read_from='file', path=None, checkpaths=True): | 93 def make_ui(read_from='file', path=None, checkpaths=True): |
87 """ | 94 """ |
88 A function that will read python rc files or database | 95 A function that will read python rc files or database |
89 and make an mercurial ui object from read options | 96 and make an mercurial ui object from read options |
90 | 97 |
127 | 134 |
128 return baseui | 135 return baseui |
129 | 136 |
130 | 137 |
131 def set_hg_app_config(config): | 138 def set_hg_app_config(config): |
132 config['hg_app_auth_realm'] = 'realm' | 139 hgsettings = get_hg_settings() |
133 config['hg_app_name'] = 'app name' | 140 config['hg_app_auth_realm'] = hgsettings.app_auth_realm |
141 config['hg_app_name'] = hgsettings.app_title | |
134 | 142 |
135 def invalidate_cache(name, *args): | 143 def invalidate_cache(name, *args): |
136 """Invalidates given name cache""" | 144 """Invalidates given name cache""" |
137 | 145 |
138 from beaker.cache import region_invalidate | 146 from beaker.cache import region_invalidate |