SQL validator
This commit is contained in:
@@ -68,16 +68,34 @@ def runBackground(data, callback):
|
||||
IOLoop.instance().add_callback(lambda: callback(result))
|
||||
glob.pool.apply_async(func, args, kwargs, _callback)
|
||||
|
||||
def check_arguments(arguments, arguments_filter):
|
||||
def check_arguments(tornado_inst):
|
||||
arguments = tornado_inst.request.arguments
|
||||
arguments_filter = tornado_inst.ARGS
|
||||
arguments_validator = tornado_inst.ARGS_VALIDATION
|
||||
|
||||
args = None
|
||||
|
||||
for k, v in arguments_filter.items():
|
||||
if v == argumentTypes.optional:
|
||||
return arg_filter_and(arguments, k)
|
||||
args = arg_filter_and(arguments, k)
|
||||
elif v == argumentTypes.required:
|
||||
return arg_filter_require_all(arguments, k)
|
||||
args = arg_filter_require_all(arguments, k)
|
||||
elif v == argumentTypes.one_required:
|
||||
return arg_filter_first(arguments, k, False)
|
||||
args = arg_filter_first(arguments, k, False)
|
||||
elif v == argumentTypes.only_one:
|
||||
return arg_filter_only_one(arguments, k)
|
||||
args = arg_filter_only_one(arguments, k)
|
||||
|
||||
if args:
|
||||
for k, v in arguments_validator.items():
|
||||
for i in range( len(v) ):
|
||||
if v[i] in args:
|
||||
if not k( tornado_inst.get_argument(v[i]) ):
|
||||
raise Exception("%s is not type of %s" % (v[i], k.__name__ ))
|
||||
|
||||
#for arg in args:
|
||||
# if tornado_inst.get_argument(arg) is not
|
||||
|
||||
return args
|
||||
|
||||
def arg_filter_and(arguments, filter, can_false = False):
|
||||
arg_filter = []
|
||||
|
||||
Reference in New Issue
Block a user