##// END OF EJS Templates
moved all cache function out to Base Controller for easier maintainance
marcink -
r196:568f9505 default
parent child Browse files
Show More
@@ -5,21 +5,14 from pylons import request, response, se
5 app_globals as g
5 app_globals as g
6 from pylons.controllers.util import abort, redirect
6 from pylons.controllers.util import abort, redirect
7 from pylons_app.lib.auth import LoginRequired
7 from pylons_app.lib.auth import LoginRequired
8 from pylons_app.lib.base import BaseController, render
8 from pylons_app.lib.base import BaseController, render, _full_changelog_cached
9 from pylons_app.lib.filters import age as _age, person
9 from pylons_app.lib.filters import age as _age, person
10 from pylons_app.lib.utils import get_repo_slug
10 from pylons_app.lib.utils import get_repo_slug
11 from pylons_app.model.hg_model import HgModel
11 from pylons_app.model.hg_model import HgModel
12 from simplejson import dumps
12 from simplejson import dumps
13 from webhelpers.paginate import Page
13 from webhelpers.paginate import Page
14 import logging
14 import logging
15
15 log = logging.getLogger(__name__)
16
17 @cache_region('long_term', 'full_changelog')
18 def _full_changelog_cached(repo_name):
19 hg_model = HgModel()
20 return list(reversed(list(hg_model.get_repo(repo_name))))
21
22 log = logging.getLogger(__name__)
23
16
24 class ChangelogController(BaseController):
17 class ChangelogController(BaseController):
25
18
@@ -28,16 +21,13 class ChangelogController(BaseController
28 super(ChangelogController, self).__before__()
21 super(ChangelogController, self).__before__()
29
22
30 def index(self):
23 def index(self):
31 hg_model = HgModel()
32 if request.params.get('size'):
24 if request.params.get('size'):
33 c.size = int(request.params['size'])
25 c.size = int(request.params['size'])
34 session['changelog_size'] = c.size
26 session['changelog_size'] = c.size
35 session.save()
27 session.save()
36 else:
28 else:
37 c.size = session.get('changelog_size', 20)
29 c.size = session.get('changelog_size', 20)
38
39
30
40
41 changesets = _full_changelog_cached(c.repo_name)
31 changesets = _full_changelog_cached(c.repo_name)
42
32
43 p = int(request.params.get('page', 1))
33 p = int(request.params.get('page', 1))
@@ -16,6 +16,10 from pylons_app import get_version
16 def _get_repos_cached():
16 def _get_repos_cached():
17 return [rep for rep in HgModel().get_repos()]
17 return [rep for rep in HgModel().get_repos()]
18
18
19 @cache_region('long_term', 'full_changelog')
20 def _full_changelog_cached(repo_name):
21 return list(reversed(list(HgModel().get_repo(repo_name))))
22
19 class BaseController(WSGIController):
23 class BaseController(WSGIController):
20
24
21 def __before__(self):
25 def __before__(self):
General Comments 0
You need to be logged in to leave comments. Login now