Mercurial > kallithea
annotate pylons_app/lib/base.py @ 168:e35210568664
files browser updated to use webhelpers huminizer for file size
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Fri, 21 May 2010 02:13:34 +0200 |
parents | 988477a05db6 |
children | 8e01265fb586 |
rev | line source |
---|---|
0 | 1 """The base Controller API |
2 | |
3 Provides the BaseController class for subclassing. | |
4 """ | |
5 from pylons.controllers import WSGIController | |
6 from pylons.templating import render_mako as render | |
7 from pylons_app.model import meta | |
107
5e2470ebdbc6
Added repo switcher, in base and long term caching for this.
Marcin Kuzminski <marcin@python-works.com>
parents:
51
diff
changeset
|
8 from beaker.cache import cache_region |
5e2470ebdbc6
Added repo switcher, in base and long term caching for this.
Marcin Kuzminski <marcin@python-works.com>
parents:
51
diff
changeset
|
9 from pylons import tmpl_context as c |
5e2470ebdbc6
Added repo switcher, in base and long term caching for this.
Marcin Kuzminski <marcin@python-works.com>
parents:
51
diff
changeset
|
10 from pylons_app.model.hg_model import HgModel |
0 | 11 |
134
79a4f9f1cbd6
Moved cached function for easier invalidation
Marcin Kuzminski <marcin@python-works.com>
parents:
107
diff
changeset
|
12 @cache_region('long_term', 'repo_list_2') |
79a4f9f1cbd6
Moved cached function for easier invalidation
Marcin Kuzminski <marcin@python-works.com>
parents:
107
diff
changeset
|
13 def _get_repos(): |
79a4f9f1cbd6
Moved cached function for easier invalidation
Marcin Kuzminski <marcin@python-works.com>
parents:
107
diff
changeset
|
14 return [rep['name'] for rep in HgModel().get_repos()] |
79a4f9f1cbd6
Moved cached function for easier invalidation
Marcin Kuzminski <marcin@python-works.com>
parents:
107
diff
changeset
|
15 |
0 | 16 class BaseController(WSGIController): |
107
5e2470ebdbc6
Added repo switcher, in base and long term caching for this.
Marcin Kuzminski <marcin@python-works.com>
parents:
51
diff
changeset
|
17 |
0 | 18 def __call__(self, environ, start_response): |
19 """Invoke the Controller""" | |
20 # WSGIController.__call__ dispatches to the Controller method | |
21 # the request is routed to. This routing information is | |
22 # available in environ['pylons.routes_dict'] | |
134
79a4f9f1cbd6
Moved cached function for easier invalidation
Marcin Kuzminski <marcin@python-works.com>
parents:
107
diff
changeset
|
23 c.repo_list = _get_repos() |
151
988477a05db6
moved sqlalchemy session to base.
Marcin Kuzminski <marcin@python-works.com>
parents:
134
diff
changeset
|
24 self.sa = meta.Session |
0 | 25 try: |
26 return WSGIController.__call__(self, environ, start_response) | |
27 finally: | |
51 | 28 meta.Session.remove() |