Mercurial > public > src > rhodecode
comparison pylons_app/lib/utils.py @ 366:6484963056cd
implemented cache for repeated queries in simplehg mercurial requests
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Wed, 14 Jul 2010 12:31:11 +0200 |
parents | 1ef52a70f3b7 |
children | bb8f45f6d8f9 |
comparison
equal
deleted
inserted
replaced
365:c71dc6ef36e6 | 366:6484963056cd |
---|---|
14 # | 14 # |
15 # You should have received a copy of the GNU General Public License | 15 # You should have received a copy of the GNU General Public License |
16 # along with this program; if not, write to the Free Software | 16 # along with this program; if not, write to the Free Software |
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | 17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
18 # MA 02110-1301, USA. | 18 # MA 02110-1301, USA. |
19 from beaker.cache import cache_region | |
19 | 20 |
20 """ | 21 """ |
21 Created on April 18, 2010 | 22 Created on April 18, 2010 |
22 Utilities for hg app | 23 Utilities for hg app |
23 @author: marcink | 24 @author: marcink |
73 except RepoError: | 74 except RepoError: |
74 #it means that there is no valid repo there... | 75 #it means that there is no valid repo there... |
75 log.info('%s repo is free for creation', repo_name) | 76 log.info('%s repo is free for creation', repo_name) |
76 return True | 77 return True |
77 | 78 |
79 | |
80 @cache_region('super_short_term', 'cached_hg_ui') | |
81 def get_hg_ui_cached(): | |
82 from pylons_app.model.meta import Session | |
83 sa = Session() | |
84 return sa.query(HgAppUi).all() | |
85 | |
78 def make_ui(read_from='file', path=None, checkpaths=True): | 86 def make_ui(read_from='file', path=None, checkpaths=True): |
79 """ | 87 """ |
80 A function that will read python rc files or database | 88 A function that will read python rc files or database |
81 and make an mercurial ui object from read options | 89 and make an mercurial ui object from read options |
82 | 90 |
110 baseui.setconfig(section, k, v) | 118 baseui.setconfig(section, k, v) |
111 if checkpaths:check_repo_dir(cfg.items('paths')) | 119 if checkpaths:check_repo_dir(cfg.items('paths')) |
112 | 120 |
113 | 121 |
114 elif read_from == 'db': | 122 elif read_from == 'db': |
115 from pylons_app.model.meta import Session | 123 hg_ui = get_hg_ui_cached() |
116 sa = Session() | |
117 | |
118 hg_ui = sa.query(HgAppUi).all() | |
119 for ui_ in hg_ui: | 124 for ui_ in hg_ui: |
120 baseui.setconfig(ui_.ui_section, ui_.ui_key, ui_.ui_value) | 125 baseui.setconfig(ui_.ui_section, ui_.ui_key, ui_.ui_value) |
121 | 126 |
122 | 127 |
123 return baseui | 128 return baseui |