Show More
@@ -82,7 +82,7 b' class AdminController(BaseController):' | |||
|
82 | 82 | c.new_repo = new_repo |
|
83 | 83 | c.msg = 'added repo' |
|
84 | 84 | #clear our cached list for refresh with new repo |
|
85 |
invalidate_cache('repo_list |
|
|
85 | invalidate_cache('cached_repo_list') | |
|
86 | 86 | except Exception as e: |
|
87 | 87 | c.new_repo = 'Exception when adding: %s' % new_repo |
|
88 | 88 | c.msg = str(e) |
@@ -1,7 +1,7 b'' | |||
|
1 | 1 | import os |
|
2 | 2 | from mercurial.hgweb import hgweb |
|
3 | 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 | 5 | from pylons.controllers.util import abort |
|
6 | 6 | from webob.exc import HTTPNotFound |
|
7 | 7 | class SimpleHg(object): |
@@ -22,12 +22,17 b' class SimpleHg(object):' | |||
|
22 | 22 | #since we wrap into hgweb, just reset the path |
|
23 | 23 | environ['PATH_INFO'] = '/' |
|
24 | 24 | self.baseui = make_ui() |
|
25 |
self.basepath = self.baseui.configitems('paths')[0][1] |
|
|
25 | self.basepath = self.baseui.configitems('paths')[0][1]\ | |
|
26 | .replace('*', '') | |
|
26 | 27 | self.repo_path = os.path.join(self.basepath, repo_name) |
|
27 | 28 | try: |
|
28 | 29 | app = wsgiapplication(self._make_app) |
|
29 | 30 | except Exception as e: |
|
30 | 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 | 36 | return app(environ, start_response) |
|
32 | 37 | |
|
33 | 38 | def _make_app(self): |
@@ -90,13 +90,24 b" def make_ui(path='hgwebdir.config', chec" | |||
|
90 | 90 | |
|
91 | 91 | return baseui |
|
92 | 92 | |
|
93 | def invalidate_cache(name): | |
|
93 | def invalidate_cache(name, *args): | |
|
94 | 94 | from beaker.cache import region_invalidate |
|
95 | if name == 'repo_list_2': | |
|
96 | 95 |
|
|
97 | from pylons_app.lib.base import _get_repos | |
|
98 | #clear our cached list for refresh with new repo | |
|
99 | region_invalidate(_get_repos, None, 'repo_list_2') | |
|
96 | ||
|
97 | """propaget our arguments to make sure invalidation works. First | |
|
98 | argument has to be the name of cached func name give to cache decorator | |
|
99 | without that the invalidation would not work""" | |
|
100 | tmp = [name] | |
|
101 | tmp.extend(args) | |
|
102 | args = tuple(tmp) | |
|
103 | ||
|
104 | if name == 'cached_repo_list': | |
|
105 | from pylons_app.lib.base import _get_repos_cached | |
|
106 | region_invalidate(_get_repos_cached, None, *args) | |
|
107 | ||
|
108 | if name == 'full_changelog': | |
|
109 | from pylons_app.controllers.changelog import _full_changelog_cached | |
|
110 | region_invalidate(_full_changelog_cached, None, *args) | |
|
100 | 111 | |
|
101 | 112 | from vcs.backends.base import BaseChangeset |
|
102 | 113 | from vcs.utils.lazy import LazyProperty |
General Comments 0
You need to be logged in to leave comments.
Login now