Changeset - 0fce1f9e4dce
[Not reviewed]
default
0 1 0
Marcin Kuzminski - 15 years ago 2010-09-28 22:14:16
marcin@python-works.com
removed .lower() from permission checking of cached repos list since repos can have capital letters now
1 file changed with 2 insertions and 2 deletions:
0 comments (0 inline, 0 general)
pylons_app/model/hg_model.py
Show inline comments
 
@@ -40,52 +40,52 @@ try:
 
    from vcs.backends.hg import MercurialRepository
 
except ImportError:
 
    sys.stderr.write('You have to import vcs module')
 
    raise Exception('Unable to import vcs')
 

	
 
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, initial)
 

	
 
@cache_region('long_term', 'cached_repo_list')
 
def _get_repos_cached():
 
    """return cached dict with repos
 
    """
 
    log.info('getting all repositories list')
 
    from pylons import app_globals as g
 
    return HgModel.repo_scan(g.paths[0][0], g.paths[0][1], g.baseui)
 

	
 
@cache_region('super_short_term', 'cached_repos_switcher_list')
 
def _get_repos_switcher_cached(cached_repo_list):
 
    repos_lst = []
 
    for repo in [x for x in cached_repo_list.values()]:
 
        if HasRepoPermissionAny('repository.write', 'repository.read',
 
                    'repository.admin')(repo.name.lower(), 'main page check'):
 
                    'repository.admin')(repo.name, 'main page check'):
 
            repos_lst.append((repo.name, repo.dbrepo.private,))
 
    
 
    return sorted(repos_lst, key=lambda k:k[0])
 
    return sorted(repos_lst, key=lambda k:k[0].lower())
 

	
 
@cache_region('long_term', 'full_changelog')
 
def _full_changelog_cached(repo_name):
 
    log.info('getting full changelog for %s', repo_name)
 
    return list(reversed(list(HgModel().get_repo(repo_name))))
 

	
 
class HgModel(object):
 
    """Mercurial Model
 
    """
 

	
 
    def __init__(self):
 
        pass
 
    
 
    @staticmethod
 
    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
 
        :param repos_path: path to directory it could take syntax with 
 
        * or ** for deep recursive displaying repositories
 
        """
 
        sa = meta.Session()
 
        def check_repo_dir(path):
 
            """Checks the repository
0 comments (0 inline, 0 general)