##// END OF EJS Templates
hgwebdir: refactor inner loop
Dirkjan Ochtman -
r5603:74f65f44 default
parent child Browse files
Show More
@@ -73,12 +73,26 b' class hgwebdir(object):'
73
73
74 try:
74 try:
75 try:
75 try:
76
76 virtual = req.env.get("PATH_INFO", "").strip('/')
77 virtual = req.env.get("PATH_INFO", "").strip('/')
77 if virtual.startswith('static/'):
78
79 # a static file
80 if virtual.startswith('static/') or 'static' in req.form:
78 static = os.path.join(templater.templatepath(), 'static')
81 static = os.path.join(templater.templatepath(), 'static')
82 if virtual.startswith('static/'):
79 fname = virtual[7:]
83 fname = virtual[7:]
84 else:
85 fname = req.form['static'][0]
80 req.write(staticfile(static, fname, req))
86 req.write(staticfile(static, fname, req))
81 elif virtual:
87 return
88
89 # top-level index
90 elif not virtual:
91 tmpl = self.templater(req)
92 self.makeindex(req, tmpl)
93 return
94
95 # nested indexes and hgwebs
82 repos = dict(self.repos)
96 repos = dict(self.repos)
83 while virtual:
97 while virtual:
84 real = repos.get(virtual)
98 real = repos.get(virtual)
@@ -105,17 +119,12 b' class hgwebdir(object):'
105 break
119 break
106 virtual = virtual[:up]
120 virtual = virtual[:up]
107
121
122 # prefixes not found
108 tmpl = self.templater(req)
123 tmpl = self.templater(req)
109 req.respond(404, tmpl("notfound", repo=virtual))
124 req.respond(404, tmpl("notfound", repo=virtual))
110 else:
125
111 if req.form.has_key('static'):
126 except ErrorResponse, err:
112 static = os.path.join(templater.templatepath(), "static")
113 fname = req.form['static'][0]
114 req.write(staticfile(static, fname, req))
115 else:
116 tmpl = self.templater(req)
127 tmpl = self.templater(req)
117 self.makeindex(req, tmpl)
118 except ErrorResponse, err:
119 req.respond(err.code, tmpl('error', error=err.message or ''))
128 req.respond(err.code, tmpl('error', error=err.message or ''))
120 finally:
129 finally:
121 tmpl = None
130 tmpl = None
General Comments 0
You need to be logged in to leave comments. Login now