Changeset - 7d687ed11929
[Not reviewed]
beta
0 5 0
Marcin Kuzminski - 14 years ago 2011-10-01 20:51:28
marcin@python-works.com
changed check_... functions from their stupid names to something less retarded :)
5 files changed with 13 insertions and 13 deletions:
0 comments (0 inline, 0 general)
rhodecode/config/routing.py
Show inline comments
 
@@ -17,36 +17,36 @@ def make_map(config):
 
    """Create, configure and return the routes Mapper"""
 
    rmap = Mapper(directory=config['pylons.paths']['controllers'],
 
                 always_scan=config['debug'])
 
    rmap.minimization = False
 
    rmap.explicit = False
 
    
 
    from rhodecode.lib.utils import check_repo_fast
 
    from rhodecode.lib.utils import check_repos_group_fast
 
    from rhodecode.lib.utils import is_valid_repo
 
    from rhodecode.lib.utils import is_valid_repos_group
 
    
 
    def check_repo(environ, match_dict):
 
        """
 
        check for valid repository for proper 404 handling
 
        
 
        :param environ:
 
        :param match_dict:
 
        """
 
         
 
        repo_name = match_dict.get('repo_name')
 
        return check_repo_fast(repo_name, config['base_path'])
 
        return is_valid_repo(repo_name, config['base_path'])
 

	
 
    def check_group(environ, match_dict):
 
        """
 
        check for valid repositories group for proper 404 handling
 
        
 
        :param environ:
 
        :param match_dict:
 
        """
 
        repos_group_name = match_dict.get('group_name')
 
        
 
        return check_repos_group_fast(repos_group_name, config['base_path'])
 
        return is_valid_repos_group(repos_group_name, config['base_path'])
 

	
 

	
 
    def check_int(environ, match_dict):
 
        return match_dict.get('id').isdigit()
 

	
 
    # The ErrorController route (handles 404/500 error pages); it should
rhodecode/lib/middleware/simplegit.py
Show inline comments
 
@@ -68,13 +68,13 @@ from dulwich.web import HTTPGitApplicati
 

	
 
from paste.auth.basic import AuthBasicAuthenticator
 
from paste.httpheaders import REMOTE_USER, AUTH_TYPE
 

	
 
from rhodecode.lib import safe_str
 
from rhodecode.lib.auth import authfunc, HasPermissionAnyMiddleware
 
from rhodecode.lib.utils import invalidate_cache, check_repo_fast
 
from rhodecode.lib.utils import invalidate_cache, is_valid_repo
 
from rhodecode.model.db import User
 

	
 
from webob.exc import HTTPNotFound, HTTPForbidden, HTTPInternalServerError
 

	
 
log = logging.getLogger(__name__)
 

	
 
@@ -189,13 +189,13 @@ class SimpleGit(object):
 
        #===================================================================
 

	
 
        repo_path = safe_str(os.path.join(self.basepath, repo_name))
 
        log.debug('Repository path is %s' % repo_path)
 

	
 
        # quick check if that dir exists...
 
        if check_repo_fast(repo_name, self.basepath) is False:
 
        if is_valid_repo(repo_name, self.basepath) is False:
 
            return HTTPNotFound()(environ, start_response)
 

	
 
        try:
 
            #invalidate cache on push
 
            if action == 'push':
 
                self.__invalidate_cache(repo_name)
rhodecode/lib/middleware/simplehg.py
Show inline comments
 
@@ -34,13 +34,13 @@ from mercurial.hgweb import hgweb_mod
 
from paste.auth.basic import AuthBasicAuthenticator
 
from paste.httpheaders import REMOTE_USER, AUTH_TYPE
 

	
 
from rhodecode.lib import safe_str
 
from rhodecode.lib.auth import authfunc, HasPermissionAnyMiddleware
 
from rhodecode.lib.utils import make_ui, invalidate_cache, \
 
    check_repo_fast, ui_sections
 
    is_valid_repo, ui_sections
 
from rhodecode.model.db import User
 

	
 
from webob.exc import HTTPNotFound, HTTPForbidden, HTTPInternalServerError
 

	
 
log = logging.getLogger(__name__)
 

	
 
@@ -158,13 +158,13 @@ class SimpleHg(object):
 
        
 
        baseui = make_ui('db')
 
        self.__inject_extras(repo_path, baseui, extras)
 
        
 

	
 
        # quick check if that dir exists...
 
        if check_repo_fast(repo_name, self.basepath) is False:
 
        if is_valid_repo(repo_name, self.basepath) is False:
 
            return HTTPNotFound()(environ, start_response)
 

	
 
        try:
 
            #invalidate cache on push
 
            if action == 'push':
 
                self.__invalidate_cache(repo_name)
rhodecode/lib/utils.py
Show inline comments
 
@@ -177,13 +177,13 @@ def get_repos(path, recursive=False):
 
                    for inner_scm in _get_repos(rec_path):
 
                        yield inner_scm
 

	
 
    return _get_repos(path)
 

	
 

	
 
def check_repo_fast(repo_name, base_path):
 
def is_valid_repo(repo_name, base_path):
 
    """
 
    Returns True if given path is a valid repository False otherwise
 
    :param repo_name:
 
    :param base_path:
 

	
 
    :return True: if given path is a valid repository
 
@@ -193,23 +193,23 @@ def check_repo_fast(repo_name, base_path
 
    try:
 
        get_scm(full_path)
 
        return True
 
    except VCSError:
 
        return False
 

	
 
def check_repos_group_fast(repos_group_name, base_path):
 
def is_valid_repos_group(repos_group_name, base_path):
 
    """
 
    Returns True if given path is a repos group False otherwise
 
    
 
    :param repo_name:
 
    :param base_path:
 
    """
 
    full_path = os.path.join(base_path, repos_group_name)
 
    
 
    # check if it's not a repo
 
    if check_repo_fast(repos_group_name, base_path):
 
    if is_valid_repo(repos_group_name, base_path):
 
        return False
 
    
 
    # check if it's a valid path
 
    if os.path.isdir(full_path):
 
        return True
 
    
rhodecode/model/repo.py
Show inline comments
 
@@ -298,24 +298,24 @@ class RepoModel(BaseModel):
 

	
 
        :param repo_name:
 
        :param alias:
 
        :param parent_id:
 
        :param clone_uri:
 
        """
 
        from rhodecode.lib.utils import check_repo_fast
 
        from rhodecode.lib.utils import is_valid_repo
 
        
 
        if new_parent_id:
 
            paths = Group.get(new_parent_id).full_path.split(Group.url_sep())
 
            new_parent_path = os.sep.join(paths)
 
        else:
 
            new_parent_path = ''
 

	
 
        repo_path = os.path.join(*map(lambda x:safe_str(x),
 
                                [self.repos_path, new_parent_path, repo_name]))
 

	
 
        if check_repo_fast(repo_path, self.repos_path) is False:
 
        if is_valid_repo(repo_path, self.repos_path) is False:
 
            log.info('creating repo %s in %s @ %s', repo_name, repo_path,
 
                     clone_uri)
 
            backend = get_backend(alias)
 

	
 
            backend(repo_path, create=True, src_url=clone_uri)
 

	
0 comments (0 inline, 0 general)