comparison pylons_app/controllers/hg.py @ 37:707dfdb1c7a8

Bugfix when client is using old mercurial version and not setting http accept
author marcink
date Thu, 18 Mar 2010 14:37:05 +0100
parents f93b523c0be3
children 71ffa932799d
comparison
equal deleted inserted replaced
36:846e2d8672c4 37:707dfdb1c7a8
9 import os 9 import os
10 from mercurial import ui, hg 10 from mercurial import ui, hg
11 from mercurial.error import RepoError 11 from mercurial.error import RepoError
12 from ConfigParser import ConfigParser 12 from ConfigParser import ConfigParser
13 import encodings 13 import encodings
14 from pylons.controllers.util import abort
14 log = logging.getLogger(__name__) 15 log = logging.getLogger(__name__)
15 16
16 class HgController(BaseController): 17 class HgController(BaseController):
17 18
18 def __before__(self): 19 def __before__(self):
19 c.repos_prefix = 'etelko' 20 c.repos_prefix = 'etelko'
20 21
21 def view(self, *args, **kwargs): 22 def view(self, *args, **kwargs):
22 response = g.hgapp(request.environ, self.start_response) 23 response = g.hgapp(request.environ, self.start_response)
24
25 http_accept = request.environ.get('HTTP_ACCEPT', False)
26 if not http_accept:
27 return abort(status_code=400, detail='no http accept in header')
28
23 #for mercurial protocols and raw files we can't wrap into mako 29 #for mercurial protocols and raw files we can't wrap into mako
24 if request.environ['HTTP_ACCEPT'].find("mercurial") != -1 or \ 30 if http_accept.find("mercurial") != -1 or \
25 request.environ['PATH_INFO'].find('raw-file') != -1: 31 request.environ['PATH_INFO'].find('raw-file') != -1:
26 return response 32 return response
27 try: 33 try:
28 tmpl = u''.join(response) 34 tmpl = u''.join(response)
29 template = Template(tmpl, lookup=request.environ['pylons.pylons']\ 35 template = Template(tmpl, lookup=request.environ['pylons.pylons']\