Mercurial > public > src > rhodecode
comparison pylons_app/controllers/hg.py @ 41:71ffa932799d
Added app basic auth.
Changed few deprecations for new pylons.
added sqlite logging for user actions.
author | Marcin Kuzminski <marcin@python-blog.com> |
---|---|
date | Wed, 07 Apr 2010 00:51:55 +0200 |
parents | 707dfdb1c7a8 |
children | 2e1247e62c5b |
comparison
equal
deleted
inserted
replaced
40:cbc1624cb499 | 41:71ffa932799d |
---|---|
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # -*- coding: utf-8 -*- | 2 # -*- coding: utf-8 -*- |
3 import logging | 3 import logging |
4 import os | |
4 from pylons_app.lib.base import BaseController, render | 5 from pylons_app.lib.base import BaseController, render |
5 from pylons import c, g, session, request | 6 from pylons import tmpl_context as c, app_globals as g, session, request, config |
6 from pylons_app.lib import helpers as h | 7 from pylons_app.lib import helpers as h |
7 from mako.template import Template | 8 from mako.template import Template |
8 from pprint import pprint | |
9 import os | |
10 from mercurial import ui, hg | 9 from mercurial import ui, hg |
11 from mercurial.error import RepoError | 10 from mercurial.error import RepoError |
12 from ConfigParser import ConfigParser | 11 from ConfigParser import ConfigParser |
13 import encodings | |
14 from pylons.controllers.util import abort | 12 from pylons.controllers.util import abort |
13 | |
15 log = logging.getLogger(__name__) | 14 log = logging.getLogger(__name__) |
16 | 15 |
17 class HgController(BaseController): | 16 class HgController(BaseController): |
18 | 17 |
19 def __before__(self): | 18 def __before__(self): |
20 c.repos_prefix = 'etelko' | 19 c.repos_prefix = config['repos_name'] |
21 | 20 |
22 def view(self, *args, **kwargs): | 21 def view(self, *args, **kwargs): |
23 response = g.hgapp(request.environ, self.start_response) | 22 response = g.hgapp(request.environ, self.start_response) |
24 | 23 |
25 http_accept = request.environ.get('HTTP_ACCEPT', False) | 24 http_accept = request.environ.get('HTTP_ACCEPT', False) |
31 request.environ['PATH_INFO'].find('raw-file') != -1: | 30 request.environ['PATH_INFO'].find('raw-file') != -1: |
32 return response | 31 return response |
33 try: | 32 try: |
34 tmpl = u''.join(response) | 33 tmpl = u''.join(response) |
35 template = Template(tmpl, lookup=request.environ['pylons.pylons']\ | 34 template = Template(tmpl, lookup=request.environ['pylons.pylons']\ |
36 .config['pylons.g'].mako_lookup) | 35 .config['pylons.app_globals'].mako_lookup) |
37 | 36 |
38 except (RuntimeError, UnicodeDecodeError): | 37 except (RuntimeError, UnicodeDecodeError): |
39 log.info('disabling unicode due to encoding error') | 38 log.info('disabling unicode due to encoding error') |
40 response = g.hgapp(request.environ, self.start_response) | 39 response = g.hgapp(request.environ, self.start_response) |
41 tmpl = ''.join(response) | 40 tmpl = ''.join(response) |
42 template = Template(tmpl, lookup=request.environ['pylons.pylons']\ | 41 template = Template(tmpl, lookup=request.environ['pylons.pylons']\ |
43 .config['pylons.g'].mako_lookup, disable_unicode=True) | 42 .config['pylons.app_globals'].mako_lookup, disable_unicode=True) |
44 | 43 |
45 | 44 |
46 return template.render(g=g, c=c, session=session, h=h) | 45 return template.render(g=g, c=c, session=session, h=h) |
47 | 46 |
48 | 47 |