Mercurial > kallithea
comparison pylons_app/lib/base.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 | 988477a05db6 |
children | 3380ca40cdba |
comparison
equal
deleted
inserted
replaced
168:e35210568664 | 169:8e01265fb586 |
---|---|
7 from pylons_app.model import meta | 7 from pylons_app.model import meta |
8 from beaker.cache import cache_region | 8 from beaker.cache import cache_region |
9 from pylons import tmpl_context as c | 9 from pylons import tmpl_context as c |
10 from pylons_app.model.hg_model import HgModel | 10 from pylons_app.model.hg_model import HgModel |
11 | 11 |
12 @cache_region('long_term', 'repo_list_2') | 12 @cache_region('long_term', 'cached_repo_list') |
13 def _get_repos(): | 13 def _get_repos_cached(): |
14 return [rep['name'] for rep in HgModel().get_repos()] | 14 return [rep for rep in HgModel().get_repos()] |
15 | 15 |
16 class BaseController(WSGIController): | 16 class BaseController(WSGIController): |
17 | 17 |
18 def __call__(self, environ, start_response): | 18 def __call__(self, environ, start_response): |
19 """Invoke the Controller""" | 19 """Invoke the Controller""" |
20 # WSGIController.__call__ dispatches to the Controller method | 20 # WSGIController.__call__ dispatches to the Controller method |
21 # the request is routed to. This routing information is | 21 # the request is routed to. This routing information is |
22 # available in environ['pylons.routes_dict'] | 22 # available in environ['pylons.routes_dict'] |
23 c.repo_list = _get_repos() | 23 c.cached_repo_list = _get_repos_cached() |
24 self.sa = meta.Session | 24 self.sa = meta.Session |
25 try: | 25 try: |
26 return WSGIController.__call__(self, environ, start_response) | 26 return WSGIController.__call__(self, environ, start_response) |
27 finally: | 27 finally: |
28 meta.Session.remove() | 28 meta.Session.remove() |