##// END OF EJS Templates
hgweb: return content iterator instead of using write() callable
Dirkjan Ochtman -
r6785:4879468f default
parent child Browse files
Show More
@@ -169,20 +169,20 b' class hgweb(object):'
169 169
170 170 req.write(content)
171 171 del tmpl
172 return req
172 return ''.join(content),
173 173
174 174 except revlog.LookupError, err:
175 175 req.respond(HTTP_NOT_FOUND, ctype)
176 176 msg = str(err)
177 177 if 'manifest' not in msg:
178 178 msg = 'revision not found: %s' % err.name
179 req.write(tmpl('error', error=msg))
179 return ''.join(tmpl('error', error=msg)),
180 180 except (RepoError, revlog.RevlogError), inst:
181 181 req.respond(HTTP_SERVER_ERROR, ctype)
182 req.write(tmpl('error', error=str(inst)))
182 return ''.join(tmpl('error', error=str(inst))),
183 183 except ErrorResponse, inst:
184 184 req.respond(inst.code, ctype)
185 req.write(tmpl('error', error=inst.message))
185 return ''.join(tmpl('error', error=inst.message)),
186 186
187 187 def templater(self, req):
188 188
@@ -70,8 +70,7 b' class hgwebdir(object):'
70 70
71 71 def __call__(self, env, respond):
72 72 req = wsgirequest(env, respond)
73 self.run_wsgi(req)
74 return req
73 return self.run_wsgi(req)
75 74
76 75 def run_wsgi(self, req):
77 76
@@ -90,14 +89,12 b' class hgwebdir(object):'
90 89 fname = virtual[7:]
91 90 else:
92 91 fname = req.form['static'][0]
93 req.write(staticfile(static, fname, req))
94 return
92 return staticfile(static, fname, req),
95 93
96 94 # top-level index
97 95 elif not virtual:
98 96 req.respond(HTTP_OK, ctype)
99 req.write(self.makeindex(req, tmpl))
100 return
97 return ''.join(self.makeindex(req, tmpl)),
101 98
102 99 # nested indexes and hgwebs
103 100
@@ -108,8 +105,7 b' class hgwebdir(object):'
108 105 req.env['REPO_NAME'] = virtual
109 106 try:
110 107 repo = hg.repository(self.parentui, real)
111 hgweb(repo).run_wsgi(req)
112 return
108 return hgweb(repo).run_wsgi(req)
113 109 except IOError, inst:
114 110 msg = inst.strerror
115 111 raise ErrorResponse(HTTP_SERVER_ERROR, msg)
@@ -120,8 +116,7 b' class hgwebdir(object):'
120 116 subdir = virtual + '/'
121 117 if [r for r in repos if r.startswith(subdir)]:
122 118 req.respond(HTTP_OK, ctype)
123 req.write(self.makeindex(req, tmpl, subdir))
124 return
119 return ''.join(self.makeindex(req, tmpl, subdir)),
125 120
126 121 up = virtual.rfind('/')
127 122 if up < 0:
@@ -130,11 +125,11 b' class hgwebdir(object):'
130 125
131 126 # prefixes not found
132 127 req.respond(HTTP_NOT_FOUND, ctype)
133 req.write(tmpl("notfound", repo=virtual))
128 return ''.join(tmpl("notfound", repo=virtual)),
134 129
135 130 except ErrorResponse, err:
136 131 req.respond(err.code, ctype)
137 req.write(tmpl('error', error=err.message or ''))
132 return ''.join(tmpl('error', error=err.message or '')),
138 133 finally:
139 134 tmpl = None
140 135
@@ -43,15 +43,17 b' env = {'
43 43
44 44 output = StringIO()
45 45 env['QUERY_STRING'] = 'style=atom'
46 hgweb('.', name = 'repo')(env, startrsp)
47 print output.getvalue()
46 content = hgweb('.', name = 'repo')(env, startrsp)
47 sys.stdout.write(output.getvalue())
48 sys.stdout.write(''.join(content))
48 49 print '---- ERRORS'
49 50 print errors.getvalue()
50 51
51 52 output = StringIO()
52 53 env['QUERY_STRING'] = 'style=raw'
53 hgwebdir({'repo': '.'})(env, startrsp)
54 print output.getvalue()
54 content = hgwebdir({'repo': '.'})(env, startrsp)
55 sys.stdout.write(output.getvalue())
56 sys.stdout.write(''.join(content))
55 57 print '---- ERRORS'
56 58 print errors.getvalue()
57 59 EOF
@@ -35,7 +35,6 b' 200 Script output follows'
35 35 </entry>
36 36
37 37 </feed>
38
39 38 ---- ERRORS
40 39
41 40 ---- HEADERS
@@ -45,6 +44,5 b' 200 Script output follows'
45 44
46 45 repo/
47 46
48
49 47 ---- ERRORS
50 48
@@ -44,32 +44,36 b' env = {'
44 44 output = StringIO()
45 45 env['PATH_INFO'] = '/'
46 46 env['QUERY_STRING'] = 'style=atom'
47 hgweb('.', name = 'repo')(env, startrsp)
48 print output.getvalue()
47 content = hgweb('.', name = 'repo')(env, startrsp)
48 sys.stdout.write(output.getvalue())
49 sys.stdout.write(''.join(content))
49 50 print '---- ERRORS'
50 51 print errors.getvalue()
51 52
52 53 output = StringIO()
53 54 env['PATH_INFO'] = '/file/tip/'
54 55 env['QUERY_STRING'] = 'style=raw'
55 hgweb('.', name = 'repo')(env, startrsp)
56 print output.getvalue()
56 content = hgweb('.', name = 'repo')(env, startrsp)
57 sys.stdout.write(output.getvalue())
58 sys.stdout.write(''.join(content))
57 59 print '---- ERRORS'
58 60 print errors.getvalue()
59 61
60 62 output = StringIO()
61 63 env['PATH_INFO'] = '/'
62 64 env['QUERY_STRING'] = 'style=raw'
63 hgwebdir({'repo': '.'})(env, startrsp)
64 print output.getvalue()
65 content = hgwebdir({'repo': '.'})(env, startrsp)
66 sys.stdout.write(output.getvalue())
67 sys.stdout.write(''.join(content))
65 68 print '---- ERRORS'
66 69 print errors.getvalue()
67 70
68 71 output = StringIO()
69 72 env['PATH_INFO'] = '/repo/file/tip/'
70 73 env['QUERY_STRING'] = 'style=raw'
71 hgwebdir({'repo': '.'})(env, startrsp)
72 print output.getvalue()
74 content = hgwebdir({'repo': '.'})(env, startrsp)
75 sys.stdout.write(output.getvalue())
76 sys.stdout.write(''.join(content))
73 77 print '---- ERRORS'
74 78 print errors.getvalue()
75 79 EOF
@@ -35,6 +35,24 b' 200 Script output follows'
35 35 </entry>
36 36
37 37 </feed>
38 ---- ERRORS
39
40 ---- HEADERS
41 200 Script output follows
42 ---- DATA
43 [('Content-Type', 'text/plain; charset=ascii')]
44
45 -rw-r--r-- 4 bar
46
47
48 ---- ERRORS
49
50 ---- HEADERS
51 200 Script output follows
52 ---- DATA
53 [('Content-Type', 'text/plain; charset=ascii')]
54
55 /repo/
38 56
39 57 ---- ERRORS
40 58
@@ -46,27 +64,5 b' 200 Script output follows'
46 64 -rw-r--r-- 4 bar
47 65
48 66
49
50 67 ---- ERRORS
51 68
52 ---- HEADERS
53 200 Script output follows
54 ---- DATA
55 [('Content-Type', 'text/plain; charset=ascii')]
56
57 /repo/
58
59
60 ---- ERRORS
61
62 ---- HEADERS
63 200 Script output follows
64 ---- DATA
65 [('Content-Type', 'text/plain; charset=ascii')]
66
67 -rw-r--r-- 4 bar
68
69
70
71 ---- ERRORS
72
General Comments 0
You need to be logged in to leave comments. Login now