Mercurial > kallithea
annotate pylons_app/lib/base.py @ 497:fb0c3af6031b celery
Implemented locking for task, to prevent for running the same tasks,
moved out pidlock library. Added dirsize display
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Thu, 23 Sep 2010 01:08:33 +0200 |
parents | 2a95d54b19e6 |
children | 72778dda34cf |
rev | line source |
---|---|
0 | 1 """The base Controller API |
2 | |
3 Provides the BaseController class for subclassing. | |
4 """ | |
185
3380ca40cdba
added version generation to pylons_app and showed it into template. Propagated baseController with some data for acces into each controller. Fixed simplehg middleware to get proper name of application
Marcin Kuzminski <marcin@python-works.com>
parents:
169
diff
changeset
|
5 from pylons import config, tmpl_context as c, request, session |
0 | 6 from pylons.controllers import WSGIController |
7 from pylons.templating import render_mako as render | |
373
3171614c0067
Added permissions check on repo switcher,
Marcin Kuzminski <marcin@python-works.com>
parents:
368
diff
changeset
|
8 from pylons_app import __version__ |
299
d303aacb3349
repos crud controllers - change id into repo_name for compatability, added ajax repo perm user function variuos html fixes, permissions forms and managment fixes.
Marcin Kuzminski <marcin@python-works.com>
parents:
245
diff
changeset
|
9 from pylons_app.lib import auth |
185
3380ca40cdba
added version generation to pylons_app and showed it into template. Propagated baseController with some data for acces into each controller. Fixed simplehg middleware to get proper name of application
Marcin Kuzminski <marcin@python-works.com>
parents:
169
diff
changeset
|
10 from pylons_app.lib.utils import get_repo_slug |
0 | 11 from pylons_app.model import meta |
373
3171614c0067
Added permissions check on repo switcher,
Marcin Kuzminski <marcin@python-works.com>
parents:
368
diff
changeset
|
12 from pylons_app.model.hg_model import _get_repos_cached, \ |
3171614c0067
Added permissions check on repo switcher,
Marcin Kuzminski <marcin@python-works.com>
parents:
368
diff
changeset
|
13 _get_repos_switcher_cached |
0 | 14 |
15 class BaseController(WSGIController): | |
185
3380ca40cdba
added version generation to pylons_app and showed it into template. Propagated baseController with some data for acces into each controller. Fixed simplehg middleware to get proper name of application
Marcin Kuzminski <marcin@python-works.com>
parents:
169
diff
changeset
|
16 |
3380ca40cdba
added version generation to pylons_app and showed it into template. Propagated baseController with some data for acces into each controller. Fixed simplehg middleware to get proper name of application
Marcin Kuzminski <marcin@python-works.com>
parents:
169
diff
changeset
|
17 def __before__(self): |
224
fdcef6ea3b55
Added readme, and changed version display
Marcin Kuzminski <marcin@python-works.com>
parents:
196
diff
changeset
|
18 c.hg_app_version = __version__ |
381
55377fdc1fc6
cleared global application settings.
Marcin Kuzminski <marcin@python-works.com>
parents:
373
diff
changeset
|
19 c.hg_app_name = config['hg_app_title'] |
185
3380ca40cdba
added version generation to pylons_app and showed it into template. Propagated baseController with some data for acces into each controller. Fixed simplehg middleware to get proper name of application
Marcin Kuzminski <marcin@python-works.com>
parents:
169
diff
changeset
|
20 c.repo_name = get_repo_slug(request) |
3380ca40cdba
added version generation to pylons_app and showed it into template. Propagated baseController with some data for acces into each controller. Fixed simplehg middleware to get proper name of application
Marcin Kuzminski <marcin@python-works.com>
parents:
169
diff
changeset
|
21 c.cached_repo_list = _get_repos_cached() |
373
3171614c0067
Added permissions check on repo switcher,
Marcin Kuzminski <marcin@python-works.com>
parents:
368
diff
changeset
|
22 c.repo_switcher_list = _get_repos_switcher_cached(c.cached_repo_list) |
453
2a95d54b19e6
reimplemented tags/branches menu.
Marcin Kuzminski <marcin@python-works.com>
parents:
381
diff
changeset
|
23 |
2a95d54b19e6
reimplemented tags/branches menu.
Marcin Kuzminski <marcin@python-works.com>
parents:
381
diff
changeset
|
24 if c.repo_name: |
2a95d54b19e6
reimplemented tags/branches menu.
Marcin Kuzminski <marcin@python-works.com>
parents:
381
diff
changeset
|
25 c.repository_tags = c.cached_repo_list[c.repo_name].tags |
2a95d54b19e6
reimplemented tags/branches menu.
Marcin Kuzminski <marcin@python-works.com>
parents:
381
diff
changeset
|
26 c.repository_branches = c.cached_repo_list[c.repo_name].branches |
2a95d54b19e6
reimplemented tags/branches menu.
Marcin Kuzminski <marcin@python-works.com>
parents:
381
diff
changeset
|
27 |
185
3380ca40cdba
added version generation to pylons_app and showed it into template. Propagated baseController with some data for acces into each controller. Fixed simplehg middleware to get proper name of application
Marcin Kuzminski <marcin@python-works.com>
parents:
169
diff
changeset
|
28 self.sa = meta.Session |
3380ca40cdba
added version generation to pylons_app and showed it into template. Propagated baseController with some data for acces into each controller. Fixed simplehg middleware to get proper name of application
Marcin Kuzminski <marcin@python-works.com>
parents:
169
diff
changeset
|
29 |
0 | 30 def __call__(self, environ, start_response): |
31 """Invoke the Controller""" | |
32 # WSGIController.__call__ dispatches to the Controller method | |
33 # the request is routed to. This routing information is | |
34 # available in environ['pylons.routes_dict'] | |
35 try: | |
368
e9a6783f5502
fixed user permissions bug when adding permissions to user who couldn load those because of auth decorators
Marcin Kuzminski <marcin@python-works.com>
parents:
362
diff
changeset
|
36 #putting this here makes sure that we update permissions every time |
e9a6783f5502
fixed user permissions bug when adding permissions to user who couldn load those because of auth decorators
Marcin Kuzminski <marcin@python-works.com>
parents:
362
diff
changeset
|
37 c.hg_app_user = auth.get_user(session) |
0 | 38 return WSGIController.__call__(self, environ, start_response) |
39 finally: | |
51 | 40 meta.Session.remove() |