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):
39 def get(cls, req, create = True):
40 sess = cls.sessdb().get(req)
53 return session.default.val
55 class autodirty(sessiondata):
58 ret = super(autodirty, cls).get(req)
59 if "_is_dirty" not in ret.__dict__:
60 ret.__dict__["_is_dirty"] = False
64 self.__dict__["_is_dirty"] = False
69 def __setattr__(self, name, value):
70 super(autodirty, self).__setattr__(name, value)
71 if "_is_dirty" in self.__dict__:
72 self.__dict__["_is_dirty"] = True
74 def __delattr__(self, name):
75 super(autodirty, self).__delattr__(name, value)
76 if "_is_dirty" in self.__dict__:
77 self.__dict__["_is_dirty"] = True
79 class manudirty(object):
80 def __init__(self, *args, **kwargs):
81 super(manudirty, self).__init__(*args, **kwargs)