annotate pylons_app/controllers/shortlog.py @ 169:8e01265fb586

added long term caching of repo_list to the base controller. changed hg and repos to use that cached list.
author Marcin Kuzminski <marcin@python-works.com>
date Fri, 21 May 2010 02:17:13 +0200
parents 20dc7a5eb748
children b68b2246e5a6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
83
db39d0ca5308 implemented Shortlog as seperate controller,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
1 import logging
db39d0ca5308 implemented Shortlog as seperate controller,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
2
db39d0ca5308 implemented Shortlog as seperate controller,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
3 from pylons import tmpl_context as c, app_globals as g, session, request, config, url
db39d0ca5308 implemented Shortlog as seperate controller,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
4 from pylons.controllers.util import abort, redirect
db39d0ca5308 implemented Shortlog as seperate controller,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
5
db39d0ca5308 implemented Shortlog as seperate controller,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
6 from pylons_app.lib.base import BaseController, render
db39d0ca5308 implemented Shortlog as seperate controller,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
7 from pylons_app.lib.utils import get_repo_slug
db39d0ca5308 implemented Shortlog as seperate controller,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
8 from pylons_app.model.hg_model import HgModel
db39d0ca5308 implemented Shortlog as seperate controller,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
9 from webhelpers.paginate import Page
86
e47d1db5ef20 Added few options to configs,
Marcin Kuzminski <marcin@python-blog.com>
parents: 83
diff changeset
10
83
db39d0ca5308 implemented Shortlog as seperate controller,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
11 log = logging.getLogger(__name__)
db39d0ca5308 implemented Shortlog as seperate controller,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
12
db39d0ca5308 implemented Shortlog as seperate controller,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
13 class ShortlogController(BaseController):
db39d0ca5308 implemented Shortlog as seperate controller,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
14 def __before__(self):
db39d0ca5308 implemented Shortlog as seperate controller,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
15 c.repos_prefix = config['repos_name']
db39d0ca5308 implemented Shortlog as seperate controller,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
16 c.repo_name = get_repo_slug(request)
db39d0ca5308 implemented Shortlog as seperate controller,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
17
db39d0ca5308 implemented Shortlog as seperate controller,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
18 def index(self):
db39d0ca5308 implemented Shortlog as seperate controller,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
19 hg_model = HgModel()
db39d0ca5308 implemented Shortlog as seperate controller,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
20 p = int(request.params.get('page', 1))
db39d0ca5308 implemented Shortlog as seperate controller,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
21 repo = hg_model.get_repo(c.repo_name)
93
aec4c0071cb3 added empty controllers for branches tags files graph, routing and test for them
Marcin Kuzminski <marcin@python-works.com>
parents: 86
diff changeset
22 c.repo_changesets = Page(repo, page=p, items_per_page=20)
127
20dc7a5eb748 Html changes and cleanups, made folders for html templates, implemented tags and branches pages
Marcin Kuzminski <marcin@python-works.com>
parents: 101
diff changeset
23 c.shortlog_data = render('shortlog/shortlog_data.html')
83
db39d0ca5308 implemented Shortlog as seperate controller,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
24 if request.params.get('partial'):
db39d0ca5308 implemented Shortlog as seperate controller,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
25 return c.shortlog_data
127
20dc7a5eb748 Html changes and cleanups, made folders for html templates, implemented tags and branches pages
Marcin Kuzminski <marcin@python-works.com>
parents: 101
diff changeset
26 r = render('shortlog/shortlog.html')
86
e47d1db5ef20 Added few options to configs,
Marcin Kuzminski <marcin@python-blog.com>
parents: 83
diff changeset
27 return r