From bcb7dc828d58449c88d34b0bffa7186663c90a66 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Mon, 9 Aug 2021 10:08:24 +0200 Subject: [PATCH] try to convert args to integers --- app/decorators.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/app/decorators.py b/app/decorators.py index 161ab8b554..c9cb0d7ba5 100644 --- a/app/decorators.py +++ b/app/decorators.py @@ -177,7 +177,14 @@ def scodoc7func(context): elif arg_name == "context": pos_arg_values.append(context) else: - pos_arg_values.append(req_args[arg_name]) + v = req_args[arg_name] + # try to convert all arguments to INTEGERS + # necessary for db ids and boolean values + try: + v = int(v) + except ValueError: + pass + pos_arg_values.append(v) # current_app.logger.info("pos_arg_values=%s" % pos_arg_values) # current_app.logger.info("req_args=%s" % req_args) # Add keyword arguments @@ -187,7 +194,14 @@ def scodoc7func(context): kwargs[arg_name] = REQUEST elif arg_name in req_args: # set argument kw optionnel - kwargs[arg_name] = req_args[arg_name] + v = req_args[arg_name] + # try to convert all arguments to INTEGERS + # necessary for db ids and boolean values + try: + v = int(v) + except ValueError: + pass + kwargs[arg_name] = v # current_app.logger.info( # "scodoc7func_decorator: top_level=%s, pos_arg_values=%s, kwargs=%s" # % (top_level, pos_arg_values, kwargs)