MCPcopy
hub / github.com/pyload/pyload / validate

Function validate

module/lib/bottle.py:1982–2000  ·  view source on GitHub ↗

Validates and manipulates keyword arguments by user defined callables. Handles ValueError and missing arguments by raising HTTPError(403).

(**vkargs)

Source from the content-addressed store, hash-verified

1980
1981
1982def validate(**vkargs):
1983 """
1984 Validates and manipulates keyword arguments by user defined callables.
1985 Handles ValueError and missing arguments by raising HTTPError(403).
1986 """
1987 depr('Use route wildcard filters instead.')
1988 def decorator(func):
1989 @functools.wraps(func)
1990 def wrapper(*args, **kargs):
1991 for key, value in vkargs.iteritems():
1992 if key not in kargs:
1993 abort(403, 'Missing parameter: %s' % key)
1994 try:
1995 kargs[key] = value(kargs[key])
1996 except ValueError:
1997 abort(403, 'Wrong parameter format for: %s' % key)
1998 return func(*args, **kargs)
1999 return wrapper
2000 return decorator
2001
2002
2003def auth_basic(check, realm="private", text="Access denied"):

Callers

nothing calls this directly

Calls 1

deprFunction · 0.85

Tested by

no test coverage detected