Mercurial > kallithea
comparison pylons_app/model/hg_model.py @ 373:3171614c0067
Added permissions check on repo switcher,
and cached that for super short cache.
repo switcher css updates
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Wed, 28 Jul 2010 02:25:47 +0200 |
parents | e9a6783f5502 |
children | 7fbf81447c6c |
comparison
equal
deleted
inserted
replaced
372:1fa58ca0a77e | 373:3171614c0067 |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # encoding: utf-8 | 2 # encoding: utf-8 |
3 # Model for hg app | 3 # Model for hg app |
4 # Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com> | 4 # Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com> |
5 | 5 # |
6 # This program is free software; you can redistribute it and/or | 6 # This program is free software; you can redistribute it and/or |
7 # modify it under the terms of the GNU General Public License | 7 # modify it under the terms of the GNU General Public License |
8 # as published by the Free Software Foundation; version 2 | 8 # as published by the Free Software Foundation; version 2 |
9 # of the License or (at your opinion) any later version of the license. | 9 # of the License or (at your opinion) any later version of the license. |
10 # | 10 # |
23 @author: marcink | 23 @author: marcink |
24 """ | 24 """ |
25 from beaker.cache import cache_region | 25 from beaker.cache import cache_region |
26 from mercurial import ui | 26 from mercurial import ui |
27 from mercurial.hgweb.hgwebdir_mod import findrepos | 27 from mercurial.hgweb.hgwebdir_mod import findrepos |
28 from vcs.exceptions import RepositoryError, VCSError | 28 from pylons.i18n.translation import _ |
29 from pylons_app.lib.auth import HasRepoPermissionAny | |
29 from pylons_app.model import meta | 30 from pylons_app.model import meta |
30 from pylons_app.model.db import Repository | 31 from pylons_app.model.db import Repository |
31 from sqlalchemy.orm import joinedload | 32 from sqlalchemy.orm import joinedload |
33 from vcs.exceptions import RepositoryError, VCSError | |
32 import logging | 34 import logging |
33 import os | 35 import os |
34 import sys | 36 import sys |
35 log = logging.getLogger(__name__) | 37 log = logging.getLogger(__name__) |
36 | 38 |
53 return cached dict with repos | 55 return cached dict with repos |
54 """ | 56 """ |
55 log.info('getting all repositories list') | 57 log.info('getting all repositories list') |
56 from pylons import app_globals as g | 58 from pylons import app_globals as g |
57 return HgModel.repo_scan(g.paths[0][0], g.paths[0][1], g.baseui) | 59 return HgModel.repo_scan(g.paths[0][0], g.paths[0][1], g.baseui) |
60 | |
61 @cache_region('super_short_term', 'cached_repos_switcher_list') | |
62 def _get_repos_switcher_cached(cached_repo_list): | |
63 repos_lst = [] | |
64 for repo in sorted(x.name.lower() for x in cached_repo_list.values()): | |
65 if HasRepoPermissionAny('repository.write', 'repository.read', 'repository.admin')(repo, 'main page check'): | |
66 repos_lst.append(repo) | |
67 | |
68 return repos_lst | |
58 | 69 |
59 @cache_region('long_term', 'full_changelog') | 70 @cache_region('long_term', 'full_changelog') |
60 def _full_changelog_cached(repo_name): | 71 def _full_changelog_cached(repo_name): |
61 log.info('getting full changelog for %s', repo_name) | 72 log.info('getting full changelog for %s', repo_name) |
62 return list(reversed(list(HgModel().get_repo(repo_name)))) | 73 return list(reversed(list(HgModel().get_repo(repo_name)))) |