Made requests shallow-cloneable.
[wrw.git] / wrw / util.py
CommitLineData
d9979128 1import req, dispatch, session
b409a338
FT
2
3def wsgiwrap(callable):
4 def wrapper(env, startreq):
0a59819d 5 return dispatch.handle(req.origrequest(env), startreq, callable)
b409a338 6 return wrapper
d9979128
FT
7
8def persession(data = None):
9 def dec(callable):
10 def wrapper(req):
11 sess = session.get(req)
12 if callable not in sess:
13 if data is None:
14 sess[callable] = callable()
15 else:
16 if data not in sess:
17 sess[data] = data()
18 sess[callable] = callable(data)
19 return sess[callable].handle(req)
20 return wrapper
21 return dec