2 import req, dispatch, session, form
4 def wsgiwrap(callable):
5 def wrapper(env, startreq):
6 return dispatch.handle(req.origrequest(env), startreq, callable)
9 def formparams(callable):
11 data = form.formdata(req)
12 spec = inspect.getargspec(callable)
13 args = dict(data.items())
16 for arg in list(args):
17 if arg not in spec.args:
19 return callable(**args)
22 def persession(data = None):
25 sess = session.get(req)
26 if callable not in sess:
28 sess[callable] = callable()
32 sess[callable] = callable(data)
33 return sess[callable].handle(req)
37 class sessiondata(object):
40 sess = cls.sessdb().get(req)
51 return session.default
53 class autodirty(sessiondata):
56 ret = super(autodirty, cls).get(req)
57 if "_is_dirty" not in ret.__dict__:
58 ret.__dict__["_is_dirty"] = False
62 self.__dict__["_is_dirty"] = False
67 def __setattr__(self, name, value):
68 super(autodirty, self).__setattr__(name, value)
69 if "_is_dirty" in self.__dict__:
70 self.__dict__["_is_dirty"] = True
72 def __delattr__(self, name):
73 super(autodirty, self).__delattr__(name, value)
74 if "_is_dirty" in self.__dict__:
75 self.__dict__["_is_dirty"] = True
77 class manudirty(object):
78 def __init__(self, *args, **kwargs):
79 super(manudirty, self).__init__(*args, **kwargs)