Show More
@@ -17,7 +17,6 b' class BaseController(WSGIController):' | |||
|
17 | 17 | c.hg_app_version = __version__ |
|
18 | 18 | c.hg_app_name = config['hg_app_name'] |
|
19 | 19 | c.repo_name = get_repo_slug(request) |
|
20 | c.hg_app_user = auth.get_user(session) | |
|
21 | 20 | c.cached_repo_list = _get_repos_cached() |
|
22 | 21 | self.sa = meta.Session |
|
23 | 22 | |
@@ -27,6 +26,8 b' class BaseController(WSGIController):' | |||
|
27 | 26 | # the request is routed to. This routing information is |
|
28 | 27 | # available in environ['pylons.routes_dict'] |
|
29 | 28 | try: |
|
29 | #putting this here makes sure that we update permissions every time | |
|
30 | c.hg_app_user = auth.get_user(session) | |
|
30 | 31 | return WSGIController.__call__(self, environ, start_response) |
|
31 | 32 | finally: |
|
32 | 33 | meta.Session.remove() |
@@ -17,13 +17,11 b'' | |||
|
17 | 17 | # along with this program; if not, write to the Free Software |
|
18 | 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 | 19 | # MA 02110-1301, USA. |
|
20 | ||
|
21 | 20 | """ |
|
22 | 21 | Created on April 9, 2010 |
|
23 | 22 | Model for hg app |
|
24 | 23 | @author: marcink |
|
25 | 24 | """ |
|
26 | ||
|
27 | 25 | from beaker.cache import cache_region |
|
28 | 26 | from mercurial import ui |
|
29 | 27 | from mercurial.hgweb.hgwebdir_mod import findrepos |
@@ -42,12 +40,12 b' except ImportError:' | |||
|
42 | 40 | sys.stderr.write('You have to import vcs module') |
|
43 | 41 | raise Exception('Unable to import vcs') |
|
44 | 42 | |
|
45 | def _get_repos_cached_initial(app_globals): | |
|
43 | def _get_repos_cached_initial(app_globals, initial): | |
|
46 | 44 | """ |
|
47 | 45 | return cached dict with repos |
|
48 | 46 | """ |
|
49 | 47 | g = app_globals |
|
50 | return HgModel.repo_scan(g.paths[0][0], g.paths[0][1], g.baseui) | |
|
48 | return HgModel.repo_scan(g.paths[0][0], g.paths[0][1], g.baseui, initial) | |
|
51 | 49 | |
|
52 | 50 | @cache_region('long_term', 'cached_repo_list') |
|
53 | 51 | def _get_repos_cached(): |
@@ -74,7 +72,7 b' class HgModel(object):' | |||
|
74 | 72 | """ |
|
75 | 73 | |
|
76 | 74 | @staticmethod |
|
77 | def repo_scan(repos_prefix, repos_path, baseui): | |
|
75 | def repo_scan(repos_prefix, repos_path, baseui, initial=False): | |
|
78 | 76 | """ |
|
79 | 77 | Listing of repositories in given path. This path should not be a |
|
80 | 78 | repository itself. Return a dictionary of repository objects |
@@ -115,8 +113,14 b' class HgModel(object):' | |||
|
115 | 113 | |
|
116 | 114 | repos_list[name] = MercurialRepository(path, baseui=baseui) |
|
117 | 115 | repos_list[name].name = name |
|
118 | dbrepo = sa.query(Repository).get(name) | |
|
116 | ||
|
117 | dbrepo = None | |
|
118 | if not initial: | |
|
119 | dbrepo = sa.query(Repository)\ | |
|
120 | .filter(Repository.repo_name == name).scalar() | |
|
121 | ||
|
119 | 122 | if dbrepo: |
|
123 | log.info('Adding db instance to cached list') | |
|
120 | 124 | repos_list[name].dbrepo = dbrepo |
|
121 | 125 | repos_list[name].description = dbrepo.description |
|
122 | 126 | repos_list[name].contact = dbrepo.user.full_contact |
General Comments 0
You need to be logged in to leave comments.
Login now