##// END OF EJS Templates
Removed unneeded PATH_INFO manipulation, and added 404 codes on bad repositories paths
marcink -
r124:f8ae5c1d default
parent child Browse files
Show More
@@ -2,6 +2,8 b' import os'
2 from mercurial.hgweb import hgweb
2 from mercurial.hgweb import hgweb
3 from mercurial.hgweb.request import wsgiapplication
3 from mercurial.hgweb.request import wsgiapplication
4 from pylons_app.lib.utils import make_ui
4 from pylons_app.lib.utils import make_ui
5 from pylons.controllers.util import abort
6 from webob.exc import HTTPNotFound
5 class SimpleHg(object):
7 class SimpleHg(object):
6
8
7 def __init__(self, application, config):
9 def __init__(self, application, config):
@@ -12,16 +14,20 b' class SimpleHg(object):'
12 if not is_mercurial(environ):
14 if not is_mercurial(environ):
13 return self.application(environ, start_response)
15 return self.application(environ, start_response)
14 else:
16 else:
15 #repo_name = environ['PATH_INFO'].replace('/', '')
17 try:
16 repo_name = environ['PATH_INFO'].split('/')[1]
18 repo_name = environ['PATH_INFO'].split('/')[1]
17 if not environ['PATH_INFO'].endswith == '/':
19 except:
18 environ['PATH_INFO'] += '/'
20 return HTTPNotFound()(environ, start_response)
19 #environ['SCRIPT_NAME'] = request.path
21
22 #since we wrap into hgweb, just reset the path
20 environ['PATH_INFO'] = '/'
23 environ['PATH_INFO'] = '/'
21 self.baseui = make_ui()
24 self.baseui = make_ui()
22 self.basepath = self.baseui.configitems('paths')[0][1].replace('*', '')
25 self.basepath = self.baseui.configitems('paths')[0][1].replace('*', '')
23 self.repo_path = os.path.join(self.basepath, repo_name)
26 self.repo_path = os.path.join(self.basepath, repo_name)
24 app = wsgiapplication(self._make_app)
27 try:
28 app = wsgiapplication(self._make_app)
29 except Exception as e:
30 return HTTPNotFound()(environ, start_response)
25 return app(environ, start_response)
31 return app(environ, start_response)
26
32
27 def _make_app(self):
33 def _make_app(self):
General Comments 0
You need to be logged in to leave comments. Login now