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