Mercurial > kallithea
comparison pylons_app/lib/simplehg.py @ 171:52bbeb1e813f
Added universal cache invalidator for two cached functions.
added invalidation when repository was added or deleted, and another invalidation when there was a mercurial command involved.
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Fri, 21 May 2010 02:44:40 +0200 |
parents | f8ae5c1dfae2 |
children | 93bd77e1f3c1 |
comparison
equal
deleted
inserted
replaced
170:f9e8920958af | 171:52bbeb1e813f |
---|---|
1 import os | 1 import os |
2 from mercurial.hgweb import hgweb | 2 from mercurial.hgweb import hgweb |
3 from mercurial.hgweb.request import wsgiapplication | 3 from mercurial.hgweb.request import wsgiapplication |
4 from pylons_app.lib.utils import make_ui | 4 from pylons_app.lib.utils import make_ui, invalidate_cache |
5 from pylons.controllers.util import abort | 5 from pylons.controllers.util import abort |
6 from webob.exc import HTTPNotFound | 6 from webob.exc import HTTPNotFound |
7 class SimpleHg(object): | 7 class SimpleHg(object): |
8 | 8 |
9 def __init__(self, application, config): | 9 def __init__(self, application, config): |
20 return HTTPNotFound()(environ, start_response) | 20 return HTTPNotFound()(environ, start_response) |
21 | 21 |
22 #since we wrap into hgweb, just reset the path | 22 #since we wrap into hgweb, just reset the path |
23 environ['PATH_INFO'] = '/' | 23 environ['PATH_INFO'] = '/' |
24 self.baseui = make_ui() | 24 self.baseui = make_ui() |
25 self.basepath = self.baseui.configitems('paths')[0][1].replace('*', '') | 25 self.basepath = self.baseui.configitems('paths')[0][1]\ |
26 .replace('*', '') | |
26 self.repo_path = os.path.join(self.basepath, repo_name) | 27 self.repo_path = os.path.join(self.basepath, repo_name) |
27 try: | 28 try: |
28 app = wsgiapplication(self._make_app) | 29 app = wsgiapplication(self._make_app) |
29 except Exception as e: | 30 except Exception as e: |
30 return HTTPNotFound()(environ, start_response) | 31 return HTTPNotFound()(environ, start_response) |
32 | |
33 """we know that some change was made to repositories and we should | |
34 invalidate the cache to see the changes right away""" | |
35 invalidate_cache('full_changelog', repo_name) | |
31 return app(environ, start_response) | 36 return app(environ, start_response) |
32 | 37 |
33 def _make_app(self): | 38 def _make_app(self): |
34 hgserve = hgweb(self.repo_path) | 39 hgserve = hgweb(self.repo_path) |
35 return self.load_web_settings(hgserve) | 40 return self.load_web_settings(hgserve) |