annotate rhodecode/lib/base.py @ 555:03676d39dd0a

added fault tolerant case when celeryconfig is not present in the directory. small form fixes, and websetup default app title and admin name
author Marcin Kuzminski <marcin@python-works.com>
date Wed, 06 Oct 2010 18:26:59 +0200
parents b75b77ef649d
children 7e536d1af60d
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
547
1e757ac98988 renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 537
diff changeset
8 from rhodecode import __version__
1e757ac98988 renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 537
diff changeset
9 from rhodecode.lib import auth
1e757ac98988 renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 537
diff changeset
10 from rhodecode.lib.utils import get_repo_slug
1e757ac98988 renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 537
diff changeset
11 from rhodecode.model import meta
1e757ac98988 renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 537
diff changeset
12 from rhodecode.model.hg_model import _get_repos_cached, \
373
3171614c0067 Added permissions check on repo switcher,
Marcin Kuzminski <marcin@python-works.com>
parents: 368
diff changeset
13 _get_repos_switcher_cached
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
14
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
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):
548
b75b77ef649d renamed hg_app to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
18 c.rhodecode_version = __version__
b75b77ef649d renamed hg_app to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
19 c.rhodecode_name = config['rhodecode_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:
535
72778dda34cf some fixups in cache, added fallback and cache invalidation when key not found in cached repos list,
Marcin Kuzminski <marcin@python-works.com>
parents: 453
diff changeset
25 cached_repo = c.cached_repo_list.get(c.repo_name)
72778dda34cf some fixups in cache, added fallback and cache invalidation when key not found in cached repos list,
Marcin Kuzminski <marcin@python-works.com>
parents: 453
diff changeset
26
72778dda34cf some fixups in cache, added fallback and cache invalidation when key not found in cached repos list,
Marcin Kuzminski <marcin@python-works.com>
parents: 453
diff changeset
27 if cached_repo:
72778dda34cf some fixups in cache, added fallback and cache invalidation when key not found in cached repos list,
Marcin Kuzminski <marcin@python-works.com>
parents: 453
diff changeset
28 c.repository_tags = cached_repo.tags
72778dda34cf some fixups in cache, added fallback and cache invalidation when key not found in cached repos list,
Marcin Kuzminski <marcin@python-works.com>
parents: 453
diff changeset
29 c.repository_branches = cached_repo.branches
72778dda34cf some fixups in cache, added fallback and cache invalidation when key not found in cached repos list,
Marcin Kuzminski <marcin@python-works.com>
parents: 453
diff changeset
30 else:
72778dda34cf some fixups in cache, added fallback and cache invalidation when key not found in cached repos list,
Marcin Kuzminski <marcin@python-works.com>
parents: 453
diff changeset
31 c.repository_tags = {}
72778dda34cf some fixups in cache, added fallback and cache invalidation when key not found in cached repos list,
Marcin Kuzminski <marcin@python-works.com>
parents: 453
diff changeset
32 c.repository_branches = {}
453
2a95d54b19e6 reimplemented tags/branches menu.
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
33
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
34 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
35
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
36 def __call__(self, environ, start_response):
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
37 """Invoke the Controller"""
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
38 # WSGIController.__call__ dispatches to the Controller method
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
39 # the request is routed to. This routing information is
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
40 # available in environ['pylons.routes_dict']
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
41 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
42 #putting this here makes sure that we update permissions every time
548
b75b77ef649d renamed hg_app to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
43 self.rhodecode_user = c.rhodecode_user = auth.get_user(session)
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
44 return WSGIController.__call__(self, environ, start_response)
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
45 finally:
51
a699c0088344 fixed sqlalchemy session bug,
marcink
parents: 17
diff changeset
46 meta.Session.remove()