Changeset - 3d1dd13887f9
[Not reviewed]
default
0 4 0
Marcin Kuzminski - 15 years ago 2010-05-22 02:20:26
marcin@python-works.com
invalidate the repo list also for online changes. Small fixes in LoginRequired decorator.
Cleaned hgwebdir config.
4 files changed with 6 insertions and 7 deletions:
0 comments (0 inline, 0 general)
hgwebdir.config
Show inline comments
 
[hooks]
 
#to do push with autoupdate
 
changegroup = hg update >&2
 

	
 
[extensions]
 
hgext.highlight=
 
#hgk=
 

	
 
[web]
 
push_ssl = false
 
allow_archive = gz zip bz2
 
allow_push = *
 
templates=/home/marcink/python_workspace/hg_app/pylons_app/templates/
 
style = monoblue_custom
 
pygments_style = trac
 
staticurl = /hg_static/
 
baseurl = /
 

	
 
[paths]
 
/ = /home/marcink/python_workspace/**
pylons_app/lib/auth.py
Show inline comments
 
@@ -74,25 +74,25 @@ class  AuthUser(object):
 
    
 
#===============================================================================
 
# DECORATORS
 
#===============================================================================
 
class LoginRequired(object):
 
    """
 
    Must be logged in to execute this function else redirect to login page
 
    """
 
    def __init__(self):
 
        pass
 
    
 
    def __call__(self, func):
 
        log.info('Checking login required')
 
        user = session.get('hg_app_user', AuthUser())
 
        log.info('Checking login required for %s', user.username)
 
        
 
        @wraps(func)
 
        def _wrapper(*fargs, **fkwargs):
 
            user = session.get('hg_app_user', AuthUser())
 
            if user.is_authenticated:
 
                    log.info('user %s is authenticated', user.username)
 
                    func(*fargs)
 
            else:
 
                logging.info('user %s not authenticated', user.username)
 
                return redirect(url('login_home'))
 

	
 
        return _wrapper
pylons_app/lib/simplehg.py
Show inline comments
 
@@ -56,24 +56,25 @@ class SimpleHg(object):
 
            self.baseui = make_ui()
 
            self.basepath = self.baseui.configitems('paths')[0][1]\
 
                                                            .replace('*', '')
 
            self.repo_path = os.path.join(self.basepath, repo_name)
 
            try:
 
                app = wsgiapplication(self._make_app)
 
            except Exception as e:
 
                return HTTPNotFound()(environ, start_response)
 
            
 
            """we know that some change was made to repositories and we should
 
            invalidate the cache to see the changes right away"""
 
            invalidate_cache('full_changelog', repo_name)
 
            invalidate_cache('cached_repo_list')
 
            return app(environ, start_response)            
 

	
 
    def _make_app(self):
 
        hgserve = hgweb(self.repo_path)
 
        return  self.load_web_settings(hgserve)
 
        
 
                
 
    def load_web_settings(self, hgserve):
 
        repoui = make_ui(os.path.join(self.repo_path, '.hg', 'hgrc'), False)
 
        #set the global ui for hgserve
 
        hgserve.repo.ui = self.baseui
 
        
pylons_app/lib/utils.py
Show inline comments
 
@@ -82,28 +82,30 @@ def make_ui(path='hgwebdir.config', chec
 
    baseui = ui.ui()
 
    cfg = config.config()
 
    cfg.read(path)
 
    if checkpaths:check_repo_dir(cfg.items('paths'))
 

	
 
    for section in sections:
 
        for k, v in cfg.items(section):
 
            baseui.setconfig(section, k, v)
 
    
 
    return baseui
 

	
 
def invalidate_cache(name, *args):
 
    """Invalidates given name cache"""
 
    
 
    from beaker.cache import region_invalidate
 
    log.info('INVALIDATING CACHE FOR %s', name)
 
    
 
    """propaget our arguments to make sure invalidation works. First
 
    """propagate our arguments to make sure invalidation works. First
 
    argument has to be the name of cached func name give to cache decorator
 
    without that the invalidation would not work"""
 
    tmp = [name]
 
    tmp.extend(args)
 
    args = tuple(tmp)
 
    
 
    if name == 'cached_repo_list':
 
        from pylons_app.lib.base import _get_repos_cached
 
        region_invalidate(_get_repos_cached, None, *args)
 
        
 
    if name == 'full_changelog':
 
        from pylons_app.controllers.changelog import _full_changelog_cached
0 comments (0 inline, 0 general)