Mercurial > kallithea
annotate rhodecode/lib/base.py @ 922:b2a70582bce3
fixed base.html. and missing lib str2bool function
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Thu, 06 Jan 2011 19:26:46 +0100 |
parents | 30ad41c76fae |
children | 042d38683d42 |
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 | |
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 |
691
7486da5f0628
Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents:
665
diff
changeset
|
12 from rhodecode.model.scm import ScmModel |
710
e2f3c8e6939d
Disable git support due to large problems with dulwich.
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
13 from rhodecode import BACKENDS |
665
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
659
diff
changeset
|
14 |
0 | 15 class BaseController(WSGIController): |
659
758f64f3fbda
extended repo creation by repo type. fixed fork creation to maintain repo type.
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
16 |
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
|
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) |
691
7486da5f0628
Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents:
665
diff
changeset
|
21 c.cached_repo_list = ScmModel().get_repos() |
659
758f64f3fbda
extended repo creation by repo type. fixed fork creation to maintain repo type.
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
22 c.backends = BACKENDS.keys() |
812
30ad41c76fae
fixes #79 cut off limit was added into .ini config files
Marcin Kuzminski <marcin@python-works.com>
parents:
784
diff
changeset
|
23 self.cut_off_limit = int(config['cut_off_limit']) |
784
30d3161c6683
Implemented fancier top menu for logged and anonymous users
Marcin Kuzminski <marcin@python-works.com>
parents:
747
diff
changeset
|
24 self.sa = meta.Session() |
30d3161c6683
Implemented fancier top menu for logged and anonymous users
Marcin Kuzminski <marcin@python-works.com>
parents:
747
diff
changeset
|
25 scm_model = ScmModel(self.sa) |
30d3161c6683
Implemented fancier top menu for logged and anonymous users
Marcin Kuzminski <marcin@python-works.com>
parents:
747
diff
changeset
|
26 #c.unread_journal = scm_model.get_unread_journal() |
30d3161c6683
Implemented fancier top menu for logged and anonymous users
Marcin Kuzminski <marcin@python-works.com>
parents:
747
diff
changeset
|
27 |
453
2a95d54b19e6
reimplemented tags/branches menu.
Marcin Kuzminski <marcin@python-works.com>
parents:
381
diff
changeset
|
28 if c.repo_name: |
747
2f89beda06a1
Added icons with numbers of followers and number of forks
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
29 cached_repo = scm_model.get(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
|
30 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
|
31 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
|
32 c.repository_branches = cached_repo.branches |
747
2f89beda06a1
Added icons with numbers of followers and number of forks
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
33 c.repository_followers = scm_model.get_followers(cached_repo.dbrepo.repo_id) |
2f89beda06a1
Added icons with numbers of followers and number of forks
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
34 c.repository_forks = scm_model.get_forks(cached_repo.dbrepo.repo_id) |
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
|
35 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
|
36 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
|
37 c.repository_branches = {} |
747
2f89beda06a1
Added icons with numbers of followers and number of forks
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
38 c.repository_followers = 0 |
2f89beda06a1
Added icons with numbers of followers and number of forks
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
39 c.repository_forks = 0 |
659
758f64f3fbda
extended repo creation by repo type. fixed fork creation to maintain repo type.
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
40 |
758f64f3fbda
extended repo creation by repo type. fixed fork creation to maintain repo type.
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
41 |
0 | 42 def __call__(self, environ, start_response): |
43 """Invoke the Controller""" | |
44 # WSGIController.__call__ dispatches to the Controller method | |
45 # the request is routed to. This routing information is | |
46 # available in environ['pylons.routes_dict'] | |
47 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
|
48 #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
|
49 self.rhodecode_user = c.rhodecode_user = auth.get_user(session) |
0 | 50 return WSGIController.__call__(self, environ, start_response) |
51 finally: | |
51 | 52 meta.Session.remove() |