Mercurial > public > src > rhodecode
diff pylons_app/model/hg_model.py @ 394:e9a6783f5502
fixed user permissions bug when adding permissions to user who couldn load those because of auth decorators
Small fix for hg model and injecting dbrepo into cached repos
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Tue, 27 Jul 2010 14:54:41 +0200 |
parents | 664a5b8c551a |
children | 3171614c0067 |
line wrap: on
line diff
--- a/pylons_app/model/hg_model.py Tue Jul 27 14:53:22 2010 +0200 +++ b/pylons_app/model/hg_model.py Tue Jul 27 14:54:41 2010 +0200 @@ -17,13 +17,11 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301, USA. - """ Created on April 9, 2010 Model for hg app @author: marcink """ - from beaker.cache import cache_region from mercurial import ui from mercurial.hgweb.hgwebdir_mod import findrepos @@ -42,12 +40,12 @@ sys.stderr.write('You have to import vcs module') raise Exception('Unable to import vcs') -def _get_repos_cached_initial(app_globals): +def _get_repos_cached_initial(app_globals, initial): """ return cached dict with repos """ g = app_globals - return HgModel.repo_scan(g.paths[0][0], g.paths[0][1], g.baseui) + return HgModel.repo_scan(g.paths[0][0], g.paths[0][1], g.baseui, initial) @cache_region('long_term', 'cached_repo_list') def _get_repos_cached(): @@ -74,7 +72,7 @@ """ @staticmethod - def repo_scan(repos_prefix, repos_path, baseui): + def repo_scan(repos_prefix, repos_path, baseui, initial=False): """ Listing of repositories in given path. This path should not be a repository itself. Return a dictionary of repository objects @@ -115,8 +113,14 @@ repos_list[name] = MercurialRepository(path, baseui=baseui) repos_list[name].name = name - dbrepo = sa.query(Repository).get(name) + + dbrepo = None + if not initial: + dbrepo = sa.query(Repository)\ + .filter(Repository.repo_name == name).scalar() + if dbrepo: + log.info('Adding db instance to cached list') repos_list[name].dbrepo = dbrepo repos_list[name].description = dbrepo.description repos_list[name].contact = dbrepo.user.full_contact