Added a distutils script.
[wrw.git] / wrw / dispatch.py
CommitLineData
b409a338
FT
1__all__ = ["restart"]
2
3class restart(Exception):
4 def handle(self, req):
5 pass
6
7def mangle(result):
8 try:
9 iter(result)
10 except TypeError:
11 pass
12 else:
13 return result
14 return [str(result)]
15
16def handle(req, startreq, handler):
17 try:
18 resp = [""]
19 while True:
20 try:
21 resp = handler(req)
22 break
23 except restart, i:
d7604bee 24 handler = i.handle
b409a338
FT
25 req.commit(startreq)
26 return resp
27 finally:
28 req.cleanup()