Mercurial > kallithea
comparison rhodecode/lib/base.py @ 1622:d58e514c0a39 beta
Merge with upstream
author | Liad Shani <liadff@gmail.com> |
---|---|
date | Sat, 29 Oct 2011 19:26:43 +0200 |
parents | 9353189b7675 6f06daeed294 |
children | de71a4bde097 |
comparison
equal
deleted
inserted
replaced
1621:cbc2b1913cdf | 1622:d58e514c0a39 |
---|---|
1 """The base Controller API | 1 """The base Controller API |
2 | 2 |
3 Provides the BaseController class for subclassing. | 3 Provides the BaseController class for subclassing. |
4 """ | 4 """ |
5 import logging | 5 import logging |
6 | 6 import time |
7 from pylons import config, tmpl_context as c, request, session, url | 7 from pylons import config, tmpl_context as c, request, session, url |
8 from pylons.controllers import WSGIController | 8 from pylons.controllers import WSGIController |
9 from pylons.controllers.util import redirect | 9 from pylons.controllers.util import redirect |
10 from pylons.templating import render_mako as render | 10 from pylons.templating import render_mako as render |
11 from paste.deploy.converters import asbool | 11 from paste.deploy.converters import asbool |
38 def __call__(self, environ, start_response): | 38 def __call__(self, environ, start_response): |
39 """Invoke the Controller""" | 39 """Invoke the Controller""" |
40 # WSGIController.__call__ dispatches to the Controller method | 40 # WSGIController.__call__ dispatches to the Controller method |
41 # the request is routed to. This routing information is | 41 # the request is routed to. This routing information is |
42 # available in environ['pylons.routes_dict'] | 42 # available in environ['pylons.routes_dict'] |
43 start = time.time() | |
43 try: | 44 try: |
44 # putting this here makes sure that we update permissions each time | 45 # putting this here makes sure that we update permissions each time |
45 api_key = request.GET.get('api_key') | 46 api_key = request.GET.get('api_key') |
46 user_id = getattr(session.get('rhodecode_user'), 'user_id', None) | 47 user_id = getattr(session.get('rhodecode_user'), 'user_id', None) |
47 if asbool(config.get('container_auth_enabled', False)): | 48 if asbool(config.get('container_auth_enabled', False)): |
57 'is_authenticated', False)) | 58 'is_authenticated', False)) |
58 session['rhodecode_user'] = self.rhodecode_user | 59 session['rhodecode_user'] = self.rhodecode_user |
59 session.save() | 60 session.save() |
60 return WSGIController.__call__(self, environ, start_response) | 61 return WSGIController.__call__(self, environ, start_response) |
61 finally: | 62 finally: |
63 log.debug('Request time: %.3fs' % (time.time()-start)) | |
62 meta.Session.remove() | 64 meta.Session.remove() |
63 | 65 |
64 | 66 |
65 class BaseRepoController(BaseController): | 67 class BaseRepoController(BaseController): |
66 """ | 68 """ |