Merge branch 'master' into python3
authorFredrik Tolf <fredrik@dolda2000.com>
Fri, 30 Dec 2011 01:34:20 +0000 (02:34 +0100)
committerFredrik Tolf <fredrik@dolda2000.com>
Fri, 30 Dec 2011 01:34:20 +0000 (02:34 +0100)
Conflicts:
wrw/__init__.py
wrw/util.py

wrw/__init__.py
wrw/util.py

index 8cc06b1..d4b0a63 100644 (file)
@@ -1,6 +1,6 @@
 __all__ = ["wsgiwrap", "restart", "cookie", "formdata"]
 
-from .util import wsgiwrap, persession, sessiondata
+from .util import wsgiwrap, formparams, persession, sessiondata, autodirty, manudirty
 from .dispatch import restart
 from . import cookie
 from .form import formdata
index 1c2ed6f..35cd3ae 100644 (file)
@@ -1,10 +1,24 @@
-from . import req, dispatch, session
+import inspect
+from . import req, dispatch, session, form
 
 def wsgiwrap(callable):
     def wrapper(env, startreq):
         return dispatch.handle(req.origrequest(env), startreq, callable)
     return wrapper
 
+def formparams(callable):
+    def wrapper(req):
+        data = form.formdata(req)
+        spec = inspect.getargspec(callable)
+        args = dict(data.items())
+        args["req"] = req
+        if not spec.keywords:
+            for arg in list(args):
+                if arg not in spec.args:
+                    del args[arg]
+        return callable(**args)
+    return wrapper
+
 def persession(data = None):
     def dec(callable):
         def wrapper(req):