annotate pylons_app/lib/base.py @ 368:e9a6783f5502

fixed user permissions bug when adding permissions to user who couldn load those because of auth decorators Small fix for hg model and injecting dbrepo into cached repos
author Marcin Kuzminski <marcin@python-works.com>
date Tue, 27 Jul 2010 14:54:41 +0200
parents 558eb7c5028f
children 3171614c0067
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
1 """The base Controller API
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
2
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
3 Provides the BaseController class for subclassing.
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
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
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
6 from pylons.controllers import WSGIController
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
7 from pylons.templating import render_mako as render
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
8 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
9 from pylons_app.lib.utils import get_repo_slug
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
10 from pylons_app.model import meta
245
a83a1799480c Reimplemented way of caching repos list, hg model now get's repos objects right from cached dict, this way we skipp creating instances of MercurialRepository and gain performance. Some import cleanup
Marcin Kuzminski <marcin@python-works.com>
parents: 224
diff changeset
11 from pylons_app.model.hg_model import _get_repos_cached
224
fdcef6ea3b55 Added readme, and changed version display
Marcin Kuzminski <marcin@python-works.com>
parents: 196
diff changeset
12 from pylons_app import __version__
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
13
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
14 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
15
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 def __before__(self):
224
fdcef6ea3b55 Added readme, and changed version display
Marcin Kuzminski <marcin@python-works.com>
parents: 196
diff changeset
17 c.hg_app_version = __version__
362
558eb7c5028f version bump to 0.8
Marcin Kuzminski <marcin@python-works.com>
parents: 299
diff changeset
18 c.hg_app_name = config['hg_app_name']
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
19 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
20 c.cached_repo_list = _get_repos_cached()
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 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
22
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
23 def __call__(self, environ, start_response):
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
24 """Invoke the Controller"""
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
25 # WSGIController.__call__ dispatches to the Controller method
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
26 # the request is routed to. This routing information is
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
27 # available in environ['pylons.routes_dict']
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
28 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
29 #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
30 c.hg_app_user = auth.get_user(session)
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
31 return WSGIController.__call__(self, environ, start_response)
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
32 finally:
51
a699c0088344 fixed sqlalchemy session bug,
marcink
parents: 17
diff changeset
33 meta.Session.remove()