comparison pylons_app/controllers/hg.py @ 21:fac1f62a1d71

Wrapped into mako templates, changed templates info. Added session and cache middleware.
author Marcin Kuzminski
date Sun, 28 Feb 2010 02:24:44 +0100
parents bbaab7501c1a
children 3142616771cd
comparison
equal deleted inserted replaced
20:bbaab7501c1a 21:fac1f62a1d71
11 from ConfigParser import ConfigParser 11 from ConfigParser import ConfigParser
12 12
13 log = logging.getLogger(__name__) 13 log = logging.getLogger(__name__)
14 14
15 class HgController(BaseController): 15 class HgController(BaseController):
16 def index(self): 16
17 return g.hgapp(request.environ, self.start_response) 17 def __before__(self):
18 c.repos_prefix = 'etelko'
19
18 20
19 def view(self, *args, **kwargs): 21 def view(self, *args, **kwargs):
20 return g.hgapp(request.environ, self.start_response) 22 response = g.hgapp(request.environ, self.start_response)
23 #for mercurial protocols we can't wrap into mako
24 if request.environ['HTTP_ACCEPT'].find("mercurial") >= 0:
25 return response
26
27 #wrap the murcurial response in a mako template.
28 template = Template("".join(response),
29 lookup = request.environ['pylons.pylons']\
30 .config['pylons.g'].mako_lookup)
31
32 return template.render(g = g, c = c, session = session, h = h)
21 33
22 def add_repo(self, new_repo): 34 def add_repo(self, new_repo):
23 c.staticurl = g.statics 35 c.staticurl = g.statics
24 36
25 #extra check it can be add since it's the command 37 #extra check it can be add since it's the command