# HG changeset patch # User Marcin Kuzminski # Date 1280235281 -7200 # Node ID e9a6783f5502f2339592f7171b9b6a80a69db305 # Parent a26f48ad7a8a294c71d88978e464c2d5023052ff 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 diff -r a26f48ad7a8a -r e9a6783f5502 pylons_app/lib/base.py --- a/pylons_app/lib/base.py Tue Jul 27 14:53:22 2010 +0200 +++ b/pylons_app/lib/base.py Tue Jul 27 14:54:41 2010 +0200 @@ -17,7 +17,6 @@ c.hg_app_version = __version__ c.hg_app_name = config['hg_app_name'] c.repo_name = get_repo_slug(request) - c.hg_app_user = auth.get_user(session) c.cached_repo_list = _get_repos_cached() self.sa = meta.Session @@ -27,6 +26,8 @@ # the request is routed to. This routing information is # available in environ['pylons.routes_dict'] try: + #putting this here makes sure that we update permissions every time + c.hg_app_user = auth.get_user(session) return WSGIController.__call__(self, environ, start_response) finally: meta.Session.remove() diff -r a26f48ad7a8a -r e9a6783f5502 pylons_app/model/hg_model.py --- 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