comparison pylons_app/lib/base.py @ 134:79a4f9f1cbd6

Moved cached function for easier invalidation
author Marcin Kuzminski <marcin@python-works.com>
date Sun, 09 May 2010 13:20:34 +0200
parents 5e2470ebdbc6
children 988477a05db6
comparison
equal deleted inserted replaced
133:919b5bcd8630 134:79a4f9f1cbd6
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')
13 def _get_repos():
14 return [rep['name'] for rep in HgModel().get_repos()]
15
12 class BaseController(WSGIController): 16 class BaseController(WSGIController):
13 def _load_repos(self):
14
15 @cache_region('long_term', 'repo_list_2')
16 def _get_repos():
17 return [rep['name'] for rep in HgModel().get_repos()]
18
19 c.repo_list = _get_repos()
20 17
21 def __call__(self, environ, start_response): 18 def __call__(self, environ, start_response):
22 """Invoke the Controller""" 19 """Invoke the Controller"""
23 # WSGIController.__call__ dispatches to the Controller method 20 # WSGIController.__call__ dispatches to the Controller method
24 # the request is routed to. This routing information is 21 # the request is routed to. This routing information is
25 # available in environ['pylons.routes_dict'] 22 # available in environ['pylons.routes_dict']
26 self._load_repos() 23 c.repo_list = _get_repos()
27 try: 24 try:
28 return WSGIController.__call__(self, environ, start_response) 25 return WSGIController.__call__(self, environ, start_response)
29 finally: 26 finally:
30 meta.Session.remove() 27 meta.Session.remove()