Dolda2000 GitWeb
/
wrw.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
77dd732
)
Error out more usefully from formparams when required parameters are missing.
author
Fredrik Tolf
<fredrik@dolda2000.com>
Sat, 6 Apr 2013 16:06:41 +0000
(18:06 +0200)
committer
Fredrik Tolf
<fredrik@dolda2000.com>
Sat, 6 Apr 2013 16:06:41 +0000
(18:06 +0200)
wrw/util.py
patch
|
blob
|
blame
|
history
diff --git
a/wrw/util.py
b/wrw/util.py
index
55b4ee2
..
64b820f
100644
(file)
--- a/
wrw/util.py
+++ b/
wrw/util.py
@@
-1,5
+1,5
@@
import inspect
import inspect
-import req, dispatch, session, form
+import req, dispatch, session, form
, resp
def wsgiwrap(callable):
def wrapper(env, startreq):
def wsgiwrap(callable):
def wrapper(env, startreq):
@@
-16,6
+16,9
@@
def formparams(callable):
for arg in list(args):
if arg not in spec.args:
del args[arg]
for arg in list(args):
if arg not in spec.args:
del args[arg]
+ for i in xrange(len(spec.args) - len(spec.defaults)):
+ if spec.args[i] not in args:
+ raise resp.httperror(400, "Missing parameter", ("The query parameter `", resp.h.code(spec.args[i]), "' is required but not supplied."))
return callable(**args)
return wrapper
return callable(**args)
return wrapper