Mercurial > kallithea
comparison pylons_app/controllers/hg.py @ 10:525ed90e4577
major app speedup moved the wsgi creation to app globals, in order to make it run only once.
little config changes.
author | Marcin Kuzminski |
---|---|
date | Sat, 20 Feb 2010 14:30:13 +0100 |
parents | 3092016c6d0c |
children | 5f30a6d558dc |
comparison
equal
deleted
inserted
replaced
9:058f63b6c2ff | 10:525ed90e4577 |
---|---|
4 from pylons_app.lib.base import BaseController | 4 from pylons_app.lib.base import BaseController |
5 from pylons import c, g, session, h, request | 5 from pylons import c, g, session, h, request |
6 from mako.template import Template | 6 from mako.template import Template |
7 from pprint import pprint | 7 from pprint import pprint |
8 import os | 8 import os |
9 #uncomment the following if you want to serve a single repo | |
10 #from mercurial.hgweb.hgweb_mod import hgweb | |
11 from mercurial.hgweb.hgwebdir_mod import hgwebdir | |
12 from mercurial.hgweb.request import wsgiapplication | |
13 log = logging.getLogger(__name__) | |
14 | |
15 from mercurial import ui, hg | 9 from mercurial import ui, hg |
16 from mercurial.error import RepoError | 10 from mercurial.error import RepoError |
17 from ConfigParser import ConfigParser | 11 from ConfigParser import ConfigParser |
18 | 12 |
19 def make_web_app(): | 13 log = logging.getLogger(__name__) |
20 repos = "hgwebdir.config" | |
21 hgwebapp = hgwebdir(repos) | |
22 return hgwebapp | |
23 | 14 |
24 class HgController(BaseController): | 15 class HgController(BaseController): |
25 #based on | |
26 #http://bel-epa.com/hg/ | |
27 def index(self): | 16 def index(self): |
28 hgapp = wsgiapplication(make_web_app) | 17 return g.hgapp(request.environ, self.start_response) |
29 return hgapp(request.environ, self.start_response) | |
30 | 18 |
31 def view(self, *args, **kwargs): | 19 def view(self, *args, **kwargs): |
32 hgapp = wsgiapplication(make_web_app) | 20 return g.hgapp(request.environ, self.start_response) |
33 return hgapp(request.environ, self.start_response) | |
34 | 21 |
35 def add_repo(self, new_repo): | 22 def add_repo(self, new_repo): |
36 tmpl = ''' | 23 tmpl = ''' |
37 <html> | 24 <html> |
38 <body> | 25 <body> |
56 return [tmpl % ({'new_repo':new_repo, 'msg':'added repo: '})] | 43 return [tmpl % ({'new_repo':new_repo, 'msg':'added repo: '})] |
57 | 44 |
58 def _check_repo(self, repo_name): | 45 def _check_repo(self, repo_name): |
59 p = os.path.dirname(__file__) | 46 p = os.path.dirname(__file__) |
60 config_path = os.path.join(p, '../..', 'hgwebdir.config') | 47 config_path = os.path.join(p, '../..', 'hgwebdir.config') |
61 print config_path | |
62 | 48 |
63 cp = ConfigParser() | 49 cp = ConfigParser() |
64 | 50 |
65 cp.read(config_path) | 51 cp.read(config_path) |
66 repos_path = cp.get('paths', '/').replace("**", '') | 52 repos_path = cp.get('paths', '/').replace("**", '') |